Extracting icons with imagemagick creates black stripes on transparency - imagemagick

For a project of mine I'm fetching websites favicons and storing them to be displayed in a website. Sounds pretty trivial, but I have one strange issue. Almost all icons come in a .ico format, which is not very web friendly. Some icons also have different sizes in them.
I'm using Imagemagick to convert them to PNG and extract only the 16x16 icon.
I'm using the following command line for this:
convert source.ico -geometry 16x16 -alpha on -background none -flatten out.png
Unfortunately on some icons this creates some nasty horizontal black stripes in the transparent areas. Here is an example:
This is the original icon:
http://g.etfv.co/http://www.mysqlperformanceblog.com/
This is the result:
http://img585.imageshack.us/img585/1463/65407408.png
Here it is again embedded here:
What could be wrong here? My ImageMagick is version 6.5.4-7

Try updating your Imagemagick installation: I tried your command with your .ico file with version 6.6.0-1 and it created the png file correctly
Version: ImageMagick 6.6.0-1 2010-03-03 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
Features: OpenMP

Related

conversion from xRGB to cmyk imagemagick

I am trying to convert an jpeg image from rgb to cmyk colorspace. Platform is ubuntu 14.04 lts, imagemagick 6.7.7-10
I start with two versions of the image, both rgb. One has an embedded sRGB profile, the other has AdobeRGB. Both are displayer fairly the same in Firefox or Gwenview, quite similar in EOG.
When I convert both images to cmyk using imagemagick:
convert input.jpg -colorspace cmyk test.jpg
then I get two files, that are displayed quite differently. One is considerably darker than the other and both are too dark. It looks like the original profiles have not been used to correctly compute new color values.
One more thing that I observed is, that the resulting image from the xRGB to CMYK conversion still appears to have the AdobeRGB profile embedded, when asking with "identify":
>$ identify -verbose test.jpg | grep -A 5 rofile
Profiles:
Profile-exif: 36738 bytes
Profile-icc: 560 bytes
Description: Adobe RGB (1998)
Manufacturer: Adobe RGB (1998)
Model: Adobe RGB (1998)
Copyright: Copyright 2000 Adobe Systems Incorporated
My understanding is, that a CMYK colorspace cannoth use a RGB profile.
Question: What's wrong in my understanding/usage of ImageMagick or Colorspaces/profiles?
To change both the color model and the ICC profile, I found it necessary to use both -profile and -colorspace. Like this:
convert image.jpg -colorspace CMYK -profile USWebCoatedSWOP.icc image_CMYK_cspace_profile.jpg
Many viewers will not display CMYK JPG correctly unless there is a CMYK profile. If you have an RGB image with a profile, then use profiles to convert rather than -colorspace. In ImageMagick do the following:
convert rgb.jpg -profile path/to/USWebCoatedSwop.icc cmyk.jpg
If the RGB has no profile, then you want to add the rgb profile before the CMYK profile
convert rgb.jpg -profile path/to/sRGB.icc -profile path/to/USWebCoatedSwop.icc cmyk.jpg
Also 6.7.7.10 is rather old and was a release during which many colorspace changes were occurring in ImageMagick. So I strong urge you to upgrade. At the time I write this, it is at 6.9.9.40 and 7.0.7.38.
I think you are confusing colorspaces with profiles. If you just change the colorspace, with -colorspace cmyk, you will only change the colorspace and not the profile, so your existing profile will remain embedded, as you have seen.
I think you need
convert input.jpg -profile cmyk.icm result.jpg
There is an excellent discussion, by Anthony Thyssen, here.

How to keep transparent background in GraphicsMagick .ai to .png conversion?

I'm using a GraphicsMagick package for image processing
When converting Illustrator (.ai) files to .png files, I end up losing transparency so the background ends up white.
I don't have this problem when using the same options and converting with ImageMagick, but I need a solution to make it work with GraphicsMagick specifically.
I don't have much experience with GraphicsMagick, but I would assume that the behavior of -background is the same as ImageMagick's:
gm convert -background transparent source.ai out.png
Note: This works by defining the background before reading the vector graphic

Incorporating a grayscale TIFF as alpha channel in another TIFF with ImageMagick

When I scan negatives Sane provides 16-bit grayscale files containing infrared information along with the 48-bit RGB files that contain the image information.
Is there any way to combine these two files using ImageMagick in order to obtain a 64-bit RGBA TIFF file whose Alpha channel (infrared) is somehow recognized in Photoshop? Photoshop may detect it as transparency, separate layer or even outright Alpha channel. All these are fine by me.
I haven't been able to obtain much following numerous ImageMagick tutorials on the internet. All TIFFs I get are devoid of transparency information. Libtiff's tiff2rgba does not seem to be of much help either.
My ImageMagick version information:
$ convert --version
Version: ImageMagick 6.8.8-6 Q16 x86_64 2014-02-17 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC
Delegates: bzlib fftw fontconfig freetype jng jpeg lcms lzma png tiff webp x xml zlib
I am not 100% certain I have got your filetypes and needs exactly understood, but if I create a red square TIFF like this:
convert -size 512x512 xc:red rgb.tiff
and a synthetic (faked) greysale gradient to represent your IR image, like this:
convert -size 512x512 -colorspace gray gradient:\#000000-\#ffffff ir.tiff
I can combine them using the IR as opacity like this:
convert rgb.tiff ir.tiff -compose copyopacity -composite out.tiff
to give this, which at least my version of Photoshop CC 2014 understands.
By the way. it seems equally happy creating a Photoshop PSD format directly:
convert rgb.tiff ir.tiff -compose copyopacity -composite out.psd

ImageMagick PDF to JPG thumbnails are black

I have ImageMagick version 6.6.9.7 and using convert for PDF to JPG thumbnails.
Spaces with no text on the thumbnail are black.
I've installed latest version of GhostScript, tried various methods of fixing (adding -colorspace 'rgb', -flatten, -alpha off, -background white) etc but nothings working.
Does anybody know how to fix this?
First suggestion would be to reduce the scope of the problem. Try using Ghostscript to convert the PDF to JPEG instead of using ImageMagick. If that works as exepcted then you know the problem is ImageMagick, if it doesn't then you can blame Ghostscript.
gs -sDEVICE=jpeg -o out.jpg
If that works then the problem may be in ImageMagick, or it may be the Ghostscript command line which ImageMagick is manufacturing, in which case you'll need to find out what that is, and I can't tell you how to find that out. But try the above and see what you get.

lost layer when exporting PSD to PNG with ImageMagick

We have a script which breaks a Photoshop PSD file into its three layers as PNG images, using the ImageMagick "convert" command:
convert my.psd -set dispose Background -coalesce -delete 0 temp.png
It's just like the answer to the SO question Extract layers from PSD with ImageMagick, preserving layout. We do want to see the output images aligned as in that question.
It works fine except sometimes when the middle layer is empty, that is, completely transparent. In this case it behaves as if that layer is missing, and produces PNG files for the other two layers only. How can I get all the layers?
I've been sifting through the ImageMagick documentation, trying variations on the options above, but no luck so far.
I'm on OS X 10.7.4.
$ convert -version
Version: ImageMagick 6.7.9-0 2012-08-27 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenCL

Resources