Page 1 of 1

.AI CMYK transparency error

Posted: 2017-10-05T05:00:39-07:00
by ayrton.ricardo
Hi guys,

I'm trying to do:
  • Convert a .AI file in a .PNG file;
  • Merge a .AI file with a PNG file;
In both cases the transparency isn't available, but when I use the convert command the error doesn't appear.

PHP CODE:

Code: Select all

$file1 = 'a.ai';
$out = 'c.png';

// read page 1
$im = new \Imagick();
$im->readImage($file1);
$im->setImageBackgroundColor(new \ImagickPixel('transparent'));
$im->setBackgroundColor(new \ImagickPixel('transparent'));
$im->setColorspace(\Imagick::COLORSPACE_SRGB);
$im->transformImageColorspace(\Imagick::COLORSPACE_SRGB);
$im->writeImages($out, true);
$im->clear();
$im->destroy();
Source: a.ai
Result: c.png

Command:

Code: Select all

convert -density 300 -colorspace srgb a.ai c2.png
Source: a.ai
Result: c2.png

This error only appears when the profile of colors is CMYK, when I use RGB the error doesn't appear.

Anyone know how to fix it?

Re: .AI CMYK transparency error

Posted: 2017-10-05T05:11:29-07:00
by snibgo
In PHP, try "setImageColorspace". See http://php.net/manual/en/imagick.setimagecolorspace.php

Re: .AI CMYK transparency error

Posted: 2017-10-05T06:56:24-07:00
by ayrton.ricardo
I used this option before, I tried again and the result:

CODE:

Code: Select all

// read page 1
$im = new \Imagick();
$im->readImage($file1);
$im->setImageBackgroundColor(new \ImagickPixel('transparent'));
$im->setBackgroundColor(new \ImagickPixel('transparent'));
$im->setColorspace(\Imagick::COLORSPACE_SRGB);
$im->setImageColorspace(\Imagick::COLORSPACE_SRGB); // ALTERATION
$im->transformImageColorspace(\Imagick::COLORSPACE_SRGB);
$im->writeImages($out, true);
$im->clear();
$im->destroy();

Result: c.png

I used the function `$im->negateImage(false, Imagick::CHANNEL_ALL);` but still without transparency background.

Re: .AI CMYK transparency error

Posted: 2017-10-05T10:13:07-07:00
by fmw42
Your posted images have been converted from .ai to .pdf. Please post to some place that does not change the image format or zip the files first.

Try setting the colorspace first and the background color before reading in the input AI

Code: Select all

// read page 1
$im = new \Imagick();
$im->setColorspace(\Imagick::COLORSPACE_SRGB);
$im->setBackgroundColor(new \ImagickPixel('transparent'));
$im->readImage($file1);
$im->writeImages($out, true);
$im->clear();
$im->destroy();
But I think you also need to specify the format for the output file.

Re: .AI CMYK transparency error

Posted: 2017-10-05T10:18:34-07:00
by ayrton.ricardo
I don't know how exactly that format works, but here has another .ai example: https://1drv.ms/u/s!AmISJy6AbeQ7hPIziQPfQ2dyL2XYeg

Re: .AI CMYK transparency error

Posted: 2017-10-05T10:24:15-07:00
by fmw42
ayrton.ricardo wrote: 2017-10-05T10:18:34-07:00 I don't know how exactly that format works, but here has another .ai example: https://1drv.ms/u/s!AmISJy6AbeQ7hPIziQPfQ2dyL2XYeg
That also has been changed to PDF. You must find another image hosting service or zip the AI file first before uploading.

Re: .AI CMYK transparency error

Posted: 2017-10-05T10:59:56-07:00
by ayrton.ricardo
I saved a file by Adobe Illustrator and zipped it: https://www.dropbox.com/s/qrzx51g8tfrn5 ... i.zip?dl=0

Re: .AI CMYK transparency error

Posted: 2017-10-05T15:07:50-07:00
by fmw42
This command line works fine for me.

Code: Select all

convert -colorspace sRGB -background none logo-teste.ai test.png
You just need to find the equivalent Imagick commands and do them in the same order as in my command.

Re: .AI CMYK transparency error

Posted: 2017-10-06T10:51:04-07:00
by ayrton.ricardo
fmw42 wrote: 2017-10-05T15:07:50-07:00 This command line works fine for me.

Code: Select all

convert -colorspace sRGB -background none logo-teste.ai test.png
You just need to find the equivalent Imagick commands and do them in the same order as in my command.
The command work's fine as expected, the problem is the PHP code.

Re: .AI CMYK transparency error

Posted: 2017-10-06T11:05:03-07:00
by fmw42
Sorry I do not know Imagick that well.

Re: .AI CMYK transparency error

Posted: 2017-11-07T12:19:37-07:00
by ayrton.ricardo
Hi,

After update Ghostscript the problem was solved to ".ai" file, but eps still with problem if I use shadow on file.

Code: Select all

convert -background none -density 300 -colorspace sRGB teste-sombra-rgb.ai 2.png
The files:
teste-sombra-rgb.ai
teste-sombra-cmyk.ai

teste-sombra-cmyk copiar.eps
teste-sombra-rgb.eps