How to save a NSImage as a new file

You could add a category to NSImage like this @interface NSImage(saveAsJpegWithName) – (void) saveAsJpegWithName:(NSString*) fileName; @end @implementation NSImage(saveAsJpegWithName) – (void) saveAsJpegWithName:(NSString*) fileName { // Cache the reduced image NSData *imageData = [self TIFFRepresentation]; NSBitmapImageRep *imageRep = [NSBitmapImageRep imageRepWithData:imageData]; NSDictionary *imageProps = [NSDictionary dictionaryWithObject:[NSNumber numberWithFloat:1.0] forKey:NSImageCompressionFactor]; imageData = [imageRep representationUsingType:NSJPEGFileType properties:imageProps]; [imageData writeToFile:fileName atomically:NO]; } @end … Read more

Best way to convert pdf files to tiff files [closed]

Use Imagemagick, or better yet, Ghostscript. http://www.ibm.com/developerworks/library/l-graf2/#N101C2 has an example for imagemagick: convert foo.pdf pages-%03d.tiff http://www.asmail.be/msg0055376363.html has an example for ghostscript: gs -q -dNOPAUSE -sDEVICE=tiffg4 -sOutputFile=a.tif foo.pdf -c quit I would install ghostscript and read the man page for gs to see what exact options are needed and experiment.

Importing PNG files into Numpy?

According to the doc, scipy.misc.imread is deprecated starting SciPy 1.0.0, and will be removed in 1.2.0. Consider using imageio.imread instead. Example: import imageio im = imageio.imread(‘my_image.png’) print(im.shape) You can also use imageio to load from fancy sources: im = imageio.imread(‘http://upload.wikimedia.org/wikipedia/commons/d/de/Wikipedia_Logo_1.0.png’) Edit: To load all of the *.png files in a specific folder, you could use … Read more

Specifying width and height as percentages without skewing photo proportions in HTML

Note: it is invalid to provide percentages directly as <img> width or height attribute unless you’re using HTML 4.01 (see current spec, obsolete spec and this answer for more details). That being said, browsers will often tolerate such behaviour to support backwards-compatibility. Those percentage widths in your 2nd example are actually applying to the container … Read more

Merging two images with PHP

I got it working from one I made. <?php $dest = imagecreatefrompng(‘vinyl.png’); $src = imagecreatefromjpeg(‘cover2.jpg’); imagealphablending($dest, false); imagesavealpha($dest, true); imagecopymerge($dest, $src, 10, 9, 0, 0, 181, 180, 100); //have to play with these numbers for it to work for you, etc. header(‘Content-Type: image/png’); imagepng($dest); imagedestroy($dest); imagedestroy($src); ?>

How can I obtain the image size using a standard Python class (without using an external library)?

Here’s a Python 3 script that returns a tuple containing an image height and width for .png, .gif and .jpeg without using any external libraries (i.e., what Kurt McKee referenced). It should be relatively easy to transfer it to Python 2. import struct import imghdr def get_image_size(fname): ”’Determine the image type of fhandle and return its … Read more

how to make the blur effect with react-native?

Now you can do this without any library using the prop: blurRadius. E.g <Image style={styles.img} resizeMode=”cover” source={imgSrc} blurRadius={1} /> Explanation: the number(1) means the amount of blur you want to apply on the image, the higher the number, the blurrier the image. Unfortunately, this doesn’t work on Android yet (RN 0.40.0). Nevertheless, it could be … Read more

Python: The _imagingft C module is not installed

On Ubuntu, you need to have libfreetype-dev installed before compiling PIL. i.e. $ sudo apt-get install libfreetype6-dev $ sudo -s \# pip uninstall pil \# pip install –no-cache-dir pil PS! Running pip install as sudo will usually install packages to /usr/local/lib on most Ubuntu versions. You may consider to install Pil in a virtual environment … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)