EzDevInfo.com

imagemagick interview questions

Top imagemagick frequently asked interview questions

“Diff” an image using ImageMagick

How can I get the difference between two images? I have the original image. Someone has written on an exact duplicate of the original image. Now, I need to compare the original to the written on image and extract just the writing in image format.

Example: I have a picture of a house. Someone took a copy and wrote “Hello!” on the copy. I want to somehow compare the two pictures, remove the house, and be left with an image of the words “Hello!”.

Is this possible with ImageMagick? I know there are ways to get the statistical difference between images, but that is not what I am looking for.


Source: (StackOverflow)

Recommendation for compressing JPG files with ImageMagick

I want to compress a JPG image file with ImageMagick but can't get much difference in size. By default the output size is bigger than the input. I don't know why, but after adding some +profile options and setting down the quality I can get an smaller size but still similar to original.

The input image is 255kb, the processed image is 264kb (using +profile to remove profiles and setting quality to 70%). Is there any way to compress that image to 150kb at least? Is that possible? What ImageMagick options can I use?


Source: (StackOverflow)

Advertisements

Imagemagick can not find deletegates library for .tiff format on mac os x mountain lion

I could not convert .tiff files to other format.

Here is some debugging output:

$ convert -list configure

Path: /usr/local/Cellar/imagemagick/6.7.7-6/lib/ImageMagick/config/configure.xml

Name Value ------------------------------------------------------------------------------- CC cc CFLAGS -D_THREAD_SAFE -D_THREAD_SAFE -pthread -g -O2 -Wall -D_THREAD_SAFE -pthread CODER_PATH /usr/local/Cellar/imagemagick/6.7.7-6/lib/ImageMagick/modules-Q16/coders CONFIGURE ./configure '--disable-osx-universal-binary' '--without-perl' '--prefix=/usr/local/Cellar/imagemagick/6.7.7-6' '--disable-dependency-tracking' '--enable-shared' '--disable-static' '--without-pango' '--with-included-ltdl' '--with-modules' '--disable-openmp' '--without-gslib' '--with-gs-font-dir=/usr/local/share/ghostscript/fonts' '--without-x' 'CC=cc' 'CXX=c++' CONFIGURE_PATH /usr/local/Cellar/imagemagick/6.7.7-6/etc/ImageMagick/ COPYRIGHT
Copyright (C) 1999-2012 ImageMagick Studio LLC CPPFLAGS
-I/usr/local/Cellar/imagemagick/6.7.7-6/include/ImageMagick CXX c++ CXXFLAGS -g -O2 -D_THREAD_SAFE -pthread DEFS
-DHAVE_CONFIG_H DELEGATES bzlib freetype jpeg jng png xml zlib DISTCHECK_CONFIG_FLAGS 'CC=cc' 'CXX=c++' --disable-deprecated --with-quantum-depth=16 --with-umem=no --with-autotrace=no --with-gslib=no --with-fontpath= --with-gs-font-dir=/usr/local/share/ghostscript/fonts --with-pango=no --with-wmf=no --with-perl=no DOCUMENTATION_PATH /usr/local/Cellar/imagemagick/6.7.7-6/share/doc/ImageMagick EXEC-PREFIX /usr/local/Cellar/imagemagick/6.7.7-6 EXECUTABLE_PATH /usr/local/Cellar/imagemagick/6.7.7-6/bin FEATURES OpenCL FILTER_PATH
/usr/local/Cellar/imagemagick/6.7.7-6/lib/ImageMagick/modules-Q16/filters HOST x86_64-apple-darwin12.1.0 INCLUDE_PATH /usr/local/Cellar/imagemagick/6.7.7-6/include/ImageMagick LDFLAGS
-L/usr/local/Cellar/imagemagick/6.7.7-6/lib -L/usr/local/Cellar/freetype/2.4.10/lib LIB_VERSION 0x677 LIB_VERSION_NUMBER 6,7,7,6 LIBRARY_PATH /usr/local/Cellar/imagemagick/6.7.7-6/lib/ImageMagick LIBS
-lMagickCore -lfreetype -ljpeg -lbz2 -lz -lm -Wl,-framework,OpenCL -lm -lpthread NAME ImageMagick PCFLAGS PREFIX /usr/local/Cellar/imagemagick/6.7.7-6 QuantumDepth 16 RELEASE_DATE 2012-09-18 SHARE_PATH
/usr/local/Cellar/imagemagick/6.7.7-6/share/ImageMagick SVN_REVISION 8165 TARGET_CPU x86_64 TARGET_OS darwin12.1.0 TARGET_VENDOR apple VERSION 6.7.7 WEBSITE http://www.imagemagick.org

Path: [built-in]

Name Value ------------------------------------------------------------------------------- NAME ImageMagick

I have tried to uninstall/install libtiff, imagemagick, just won't work

$ brew uninstall libtiff

$ brew install imagemagick

$ brew uninstall imagemagick

$ brew install imagemagick

Any idea of what's wrong with my installation? Thanks in advance,


Source: (StackOverflow)

Lion (10.7) Not supporting Convert(1). Dylib error

When trying to use convert(1), I get the following error:

dyld: Library not loaded: /System/Library/Frameworks/OpenCL.framework/Versions/A/Libraries/libclparser.dylib
Referenced from: /usr/local/bin/convert
Reason: image not found
Trace/BPT trap: 5

Any idea how I could fix it ?


Source: (StackOverflow)

How to concatenate icons into a single image with ImageMagick?

I want to use CSS sprites on a web site instead of separate image files, for a large collection of small icons that are all the same size. How can I concatenate (tile) them into one big image using ImageMagick?


Source: (StackOverflow)

What packages are available for node.js to do image cropping? [closed]

I'm creating a website using node.js. I have seen many libraries mentioned that piggy back on top of imagemagick etc. There is a list here: https://github.com/ry/node/wiki/modules#graphics

What I'm trying to do is take the image that a user uploads, crop it/size it to certain dimensions the site requires. What is the best/most active script to do this? I'd like one with npm support. Does anyone have actual experience using some of these?


Source: (StackOverflow)

What is the difference for sample/resample/scale/resize/adaptive-resize/thumbnail operators in ImageMagick convert?

I found multiple ways to change the resolution of an image using convert:

-sample
-resample
-scale
-resize
-adaptive-resize
-thumbnail

What's the difference of those?

If I need to make various size large picture thumbnail with fixed aspect ratio (cropping needed) -- what's my best choice?


Source: (StackOverflow)

Converting GIF's, PNG's and JPG's to .ICO files using Imagemagick

From: JPG, To: ICO;

/usr/bin/convert -resize x16 -gravity center -crop 16x16+0+0 input.jpg \
-transparent white -colors 256 output/favicon.ico 

This is the output for the command line.

From: GIF's, PNG To: ICO;

/usr/bin/convert -resize x16 -gravity center -crop 16x16+0+0 input.png \
-flatten -colors 256 output/favicon.ico 

I am having issues with transparency. I can't seem to get the right code for it, i have tried -channel alpha -negate, etc

This creates an image and when i apply to the site, it works with Firefox but none of the other browsers. IE, Chrome, Opera and Safari all hate it for some reason, it is a simple favicon.ico file. My conclusion is it must be my command somewhere is breaking. Please help?


Source: (StackOverflow)

Resize animated GIF file without destroying animation

I need to resize an animated GIF file without destroying the animation.

How can I do it using PHP?


Source: (StackOverflow)

Converting a PDF to PNG

I'm trying to convert a PDF (at least the cover of one, I'm successfully extracting the first page of the PDF with pdftk) to a PNG. I'm using imagemagick to do the converstion:

convert cover.pdf cover.png

This works, but unfortunately the cover.png comes through incorrectly rendered (some of the alpha object in the PDF aren't rendered properly). I know ImageMagick uses GhostScript to do the conversion and if I do it directly with gs I can get the desired results, but I'd rather use the convert library as it has other tools I'd like to leverage.

This command in GhostScript accomplishes the desired image:

gs -sDEVICE=pngalpha -sOutputFile=cover.png -r144 cover.pdf

I'm wondering is there any way to pass arguments through convert to GhostScript or am I stuck with calling GhostScript directly?


Source: (StackOverflow)

Imagemagick: Convert to fixed width, proportional height

Using the imagemagick convert command, how can I resize an image to a fixed width and proportional height e.g. using the -resize or the -thumbnail option?


Source: (StackOverflow)

How to modify a homebrew formula?

I installed imagemagick via homebrew.

However, due to a bug I have with my current configuration, I need to adjust the compile flags for the formula and reinstall it.

How can I accomplish this?


Source: (StackOverflow)

Resize existing images to new style in paperclip & RMagick

I've been using paperclip to upload and auto-resize photos in my Rails app, and I love it. Only problem is about every other month my crazy manager decides he wants a new size to display the photos in. So I add a new style in my Photo model and all is good for new photos, but the pre-existing photos are now a problem. Now that I'm starting to have more than a few photos to deal with I need a programmatic way to resize existing photos. Perhaps there is some paperclip trick for such a thing? I'd really rather not have to figure out RMagick and write a script myself if I don't have to.


Source: (StackOverflow)

Verify ImageMagick installation

My web hosting said ImageMagic has been pre-installed on the server. I did a quick search for "ImageMagick" in the output of phpinfo() and I found nothing. I can't SSH in the server so is there a way in PHP I can verify the installation?


Source: (StackOverflow)

How to remove EXIF data without recompressing the JPEG?

I want to remove the EXIF information (including thumbnail, metadata, camera info... everything!) from JPEG files, but I don't want to recompress it, as recompressing the JPEG will degrade the quality, as well as usually increasing the file size.

I'm looking for a Unix/Linux solution, even better if using the command-line. If possible, using ImageMagick (convert tool). If that's not possible, a small Python, Perl, PHP (or other common language on Linux) script would be ok.

There is a similar question, but related to .NET.


Source: (StackOverflow)