Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Lagily
Posts: 3 Joined: 2018-10-15T14:19:39-07:00
Authentication code: 1152
Post
by Lagily » 2018-10-15T14:22:33-07:00
Hello
I cannot seem to be able to convert a layered AI File properly into a PNG, at least one layer seems to be missing. I am able to convert it using command line properly and am wondering how I can achieve the same using the PHP library, can anyone here help me?
This works just fine:
Code: Select all
$convertCmd = "magick convert " . APP_ROOT . "/user_content/logo_oetwil_ps.ai " . APP_ROOT . "/user_content/logo_oetwil_ps.ai.png";
exec($convertCmd);
This does not contain all the layers in the PNG:
Code: Select all
$im = new Imagick();
$im->readImage(APP_ROOT . "/user_content/logo_oetwil_ps.ai");
//$im->mergeImageLayers(\Imagick::LAYERMETHOD_FLATTEN); // This does not seem to help either
$im->setImageFormat("png");
header("Content-Type: image/png");
echo $im->getImageBlob();
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Post
by fmw42 » 2018-10-15T19:27:36-07:00
Please always provide your Imagemagick version and Platform/OS. Also provide your input AI file so we can check out the issue.
Lagily
Posts: 3 Joined: 2018-10-15T14:19:39-07:00
Authentication code: 1152
Post
by Lagily » 2018-10-16T01:26:40-07:00
I'm on Windows 10, command line:
Code: Select all
Version: ImageMagick 7.0.8-12 Q16 x86 2018-09-23 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Visual C++: 180040629
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo flif freetype gslib heic jng jp2 jpeg lcms lqr lzma openexr pangocairo png ps raw rsvg tiff webp xml zlib
PHP imagick module version: 3.4.3
AI file:
https://ufile.io/j0pek
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Post
by fmw42 » 2018-10-16T09:26:24-07:00
This works fine for me on Imagemagick 6.9.10.12 Q16 Mac OSX with
Ghostscript 9.24.
Check your version of Ghostscript and be sure it is current.
For IM 7, use magick rather than convert.
Lagily
Posts: 3 Joined: 2018-10-15T14:19:39-07:00
Authentication code: 1152
Post
by Lagily » 2018-10-16T13:31:22-07:00
Yes, the command line one works, but the PHP one does not, that is the problem... any idea why?
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Post
by fmw42 » 2018-10-16T13:36:23-07:00
It is likely due to an older version of Ghostscript. You can check your version with PHP exec() calling gs --version.
<?php
exec("gs --version",$out,$returnval);
foreach($out as $text)
{echo "$text<br>";}
?>
If you find it old, then you should upgrade it. If you are on a hosted platform, then you will need to ask the hosting provider to do the upgrade.