AI Illustrator file does not render correctly

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
graemeNPS
Posts: 64
Joined: 2009-01-12T14:25:55-07:00

AI Illustrator file does not render correctly

Post by graemeNPS »

We use ImageMagick built with static libs, 8 bit (based on ImageMagick-6.5.9) in our dll to convert a variety of image formats to jpg for use as thumbnails/previews.
We have an AI file that ImageMagick does not render correctly via our dll. It also cannot be displayed correctly in imdisplay.exe, irfanview or gsview 4.9. I have tried a couple of ghostscript releases; v8.15 and v9.00. We get a blank white image, whereas if we open the file in Illustrator, there is a graphic and logo.
Does anybody have any idea what might cause this ?


Our client has agreed to share the file with the IM community, please treat the file with confidentiality.
I have posted the file (msd_ko.ai) to our ftp site in this directory: /ImageMagick/AI-problem
Use the following credentials:
ftp.northplains.com
User name: publicforum
Password: 543publicforum123

Thanks for any assistance,
graeme
our ticket:DEF0000036300
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: AI Illustrator file does not render correctly

Post by magick »

Include a proper conversion of the image so we can compare results with what ImageMagick produces. We do not have Illustrator.
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: AI Illustrator file does not render correctly

Post by Drarakel »

Even Adobe Reader shows only a plain white surface. Or rather: a white logo (MSD) over a transparent background - but of course that is not visible when the applications use a white background.
With ImageMagick, you have to make sure that IM uses the pngalpha device from Ghostscript. I think, older IM versions sometimes had problems recognizing transparency in PDF/AI and then only used pnmraw or something like that. So, I think, your options are:
- directly using Ghostscript (with the pngalpha device)
- or updating ImageMagick (or rather your DLL?)
- or, if you want to stay with your DLL/IM version, try to change your delegates.xml (in the "ps:color" line - use "pngalpha" instead of "pnmraw")

If you have still trouble, you could first try at the commandline with something like that (and pay attention to the GS device that IM is using):

Code: Select all

convert -verbose -density 300 -colorspace RGB msd_ko.ai -trim +repage -background transparent -alpha background PNG32:logo.png
Though most of that is not really needed and with my installation (IM v6.6.7-10, GS v9.01), even a simple "convert msd_ko.ai logo.png" is successful.
graemeNPS
Posts: 64
Joined: 2009-01-12T14:25:55-07:00

Re: AI Illustrator file does not render correctly

Post by graemeNPS »

Thanks for the help, but it still isn't working for me.

In our dll, we assemble the following convert command, substituting in the input and output files:
convert -auto-orient -size 1224x792 msd_ko.ai[0] -alpha Off -resize 512x512 -profile "C:\Program Files\IPieces\profiles\sRGB.icm" +profile "*" 1308viewx.jpg

and then pass is as argv via:
status=MagickCore::ConvertImageCommand(image_info,argc,argv,(char **) NULL,&exception);

I am trying to avoid changing this command, as we have used it as-is on hundreds of thousands of image conversions.
Changing delegates.xml did not have the desired effect.

Graeme
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: AI Illustrator file does not render correctly

Post by Drarakel »

I would first try it at the commandline - with a 'normal' ImageMagick v6.5.9 (as you wrote that your DLL is based on that). If that is working for you, then you can try with your DLL.
graemeNPS wrote:I am trying to avoid changing this command, as we have used it as-is on hundreds of thousands of image conversions.
Okay, but then you won't be able to produce a reasonable output with documents like 'msd_ko.ai'. You have to decide whether it is worth adapting the command in your DLL. (I'm not even sure whether a 'one-command-fits-all' is possible with such cases.) I mean, one could say, that this type of documents is saved in a non-compatible way. As I wrote, even the official Adobe Reader (on Windows) shows only a white page with your file (with default settings). That is because regular PDF applications (AFAIK) flatten over a white background when they have transparency. And with documents that have pure white (in the normal RGB channels), with an additional alpha channel, flattening over white again produces a pure white, so that's bound to fail. But that's more the fault of the input file.

The question also is: Which result do you expect - how should the preview for 'msd_ko.ai look like? I also don't have Adobe Illustrator here, so.. How does it look like in Illustrator? Perhaps it shows the transparent regions as checkerboard or something like that. That, you could simulate with ImageMagick of course. But that would generate very strangely looking previews sometimes (text pages over a checkerboard).

So, if you decide that you want a good-looking preview for PDFs/AIs like 'msd_ko.ai', then you'll have to read a transparent image. When that is working, either keep it like that (when saving as PNG), or flatten over a non-white background (when directly saving as JPG - as JPG can't store transparency). But you can't use this type of command with every single input file. You could check whether the RGB channels only have a plain white - and only then flatten over black or something like that. Perhaps someone else has a better idea.
graemeNPS wrote:convert -auto-orient -size 1224x792 msd_ko.ai[0] -alpha Off -resize 512x512 -profile "C:\Program Files\IPieces\profiles\sRGB.icm" +profile "*" 1308viewx.jpg
Doing that fails with 'msd_ko.ai', as the information about the shape of the logo is only (!) in the alpha layer. And you are sort of deleting the alpha layer with "-alpha off". As I said, you have to flatten over e.g. black. (Additionally: I could be wrong, but I think that "-auto-orient" and "-size" are useless here - at least for PDF/AI. And adding the sRGB profile: that does something - sometimes. But if you have Ghostscript v9.00 or newer, you can leave that away, too - and instead just add "-colorspace RGB" before the input file. That way, Ghostscript will always deliver a sRGB output to ImageMagick. Much more reliable. At least that's the default with the current Ghostscript binaries for Windows.)

So, I would use a command like that:

Code: Select all

convert -colorspace RGB msd_ko.ai[0] -background black -flatten -resize 512x512 -strip 1308viewx.jpg
The logo will be very small, but that's how the input file looks like. It should even work with ImageMagick v6.5.9. But it's possible that you have to alter your delegates.xml, as described in the last post. (My IM 6.5.8 version is using 'pnmraw' as default with your file, so the command would fail without changing the delegates. If you want to know which GS device ImageMagick is using, then add "-verbose" at the commandline.)

But remember: 'background black' is only for this type of documents, not for all documents (the default is white). It IS even possible to leave away the background option here:

Code: Select all

convert -colorspace RGB msd_ko.ai[0] temp.png
convert temp.png -flatten -resize 512x512 -strip 1308viewx.jpg
That works, too. But only with a current ImageMagick version, and only due to sort of a mini-bug in the current ImageMagick.
So, I would recommend the upper command.
graemeNPS
Posts: 64
Joined: 2009-01-12T14:25:55-07:00

Re: AI Illustrator file does not render correctly

Post by graemeNPS »

Sorry, I just noticed I never thanked you for your efforts.
Thanks a lot.
graeme
Post Reply