Not correct convertation svg->png using php code - php

My svg file (m.svg)
I got some variants of svg->png conversation
First variant of png (right version):
Second variant of png:
Third variant of png:
First variant of png was made by convert command.
Second variant was made by php code.
My programs:
Ubuntu 22.04
php 8.1.7
Inkscape 1.1.2 (0a00cf5339, 2022-02-04) libxml2 librsvg2-dev (sudo apt
install ... )
ImageMagick6-6.9.11-60 ( ./configure --with-png=yes --with-rsvg=yes && make && sudo make
install && sudo ldconfig /usr/local/lib) (in phpinfo it is said that php-imagick 3.7.0 was compiled with this
version of IM)
php-imagick 3.7.0 (sudo apt install ... )
Information given by some commands:
identify -list format | grep SVG ->
MSVG* rw+ ImageMagicks own SVG internal renderer
SVG* rw+ Scalable Vector Graphics (RSVG 2.52.5)
SVGZ* rw+ Compressed Scalable Vector Graphics (RSVG 2.52.5)
phpinfo -> ImageMagick supported formats: … , MSVG, ... SVG, SVGZ, ...
convert -list configure ->
...
DELEGATES cairo fontconfig freetype jbig jng jpeg lzma png rsvg tiff x xml zlib
...
identify --version ->
Version: ImageMagick 6.9.11-60 Q16 x86_64 2021-01-24 https://imagemagick.org
Copyright: (C) 1999-2021 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC OpenMP(4.5)
Delegates (built-in): cairo fontconfig freetype jbig jng jpeg lzma png rsvg tiff x xml zlib
Results given by some commands:
rsvg-convert -o m1.png m.svg -> second variant of png
convert m.svg m.png -> first variant of png
convert SVG:m.svg m.png -> first variant of png
convert MSVG:m.svg m.png -> third variant of png
rsvg-convert gives the second variant of png (not correct). I tested another svg files (with another mistakes) and got the same result with the result made by php code.
All my svg files are rendered correctly in the Inkscape and various browsers.
If compile IM without --with-png=yes option, then php code and convert command gives third variant of png.
My questions are:
How to make php-imagick - imagemagick convert svg->png correctly?
How could be explained the difference in svg->png result between
convert command and php-imagick? As i understand convert command and
php-imagick use the same imagemagick, but the results are different.
How can I know which delegate IM uses by default?

Related

Instal ImageMagick on cpanel server

1 - I´m loged to server via SSH;
2 - I runned command yum install ImageMagick ImageMagick-devel pcre-devel;
3 - I runned command /usr/bin/convert --version;
output:
Version: ImageMagick 6.9.10-68 Q16 x86_64 2021-10-14 https://imagemagick.org
Copyright: © 1999-2019 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP(3.1)
Delegates (built-in): bzlib cairo fontconfig freetype gslib jng jp2 jpeg lcms ltdl lzma openexr pangocairo png ps rsvg tiff wmf x xml zlib
4 - my php version is 7.3.3;
5 - I runned command /opt/cpanel/ea-php73/root/usr/bin/pecl install imagick;
output:
(***)
Build process completed successfully
Installing '/opt/cpanel/ea-php73/root/usr/include/php/ext/imagick/php_imagick_sh ared.h'
Installing '/opt/cpanel/ea-php73/root/usr/lib64/php/modules/imagick.so'
install ok: channel://pecl.php.net/imagick-3.7.0
Extension imagick enabled in php.ini
6 - no imagick in phpinfo();
WHM version: 102.0.10;
What i missing?
I think the best way to install any module in Cpanel is by using Module Installers
check this
https://support.cpanel.net/hc/en-us/articles/360037048673-How-to-Install-ImageMagick-for-EA-PHP-and-ALT-PHP
also to make sure did you restart your web server after the installation?

Error 'convert: command not found' when using exec(convert ) in PHP script

I have installed my development server on my mac
Catalina 10.15.4
Apache (homebrew) => 2.4.43
PHP (homebrew) => 7.2.29
MySQL => 5.7.28
Imagemagick (homebrew) => 7.0.10
Imagick (homebrew) => 3.4.4
All Works perfectly! Except when i use imagemagick on a php script:
exec('convert -version', $debug, $return);
I get the error:
sh: convert: command not found
But when I do it on the mac Terminal, convert -version, it works! I get:
Version: ImageMagick 7.0.10-0 Q16 x86_64 2020-04-04 https://imagemagick.org
Copyright: © 1999-2020 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenMP(3.1)
Delegates (built-in): bzlib freetype gslib heic jng jp2 jpeg lcms ltdl lzma openexr png ps tiff webp xml zlib
I’ve read the following post and wasn’t able to fix it
https://stackoverflow.com/questions/28627473/error-for-convert-command-in-command-line
I did the following on the mac Terminal : which convert and I get :
/usr/local/bin/convert
My path looks like this:
PATH=/usr/local/opt/php#7.2/sbin:/usr/local/opt/php#7.2/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
When I open my phpinfo, I see the imagick, but not imagemagick, like so
At this point, I’m not sure what is the problem. Any ideas what it could be?
Use /usr/bin/magick instead.
convert is deprecated in v7+ if I am not mistaken.

ImageMagick No decode delegate for this image format

I work under windows and wamp server.
this is my PHP code with Imagick
$imagick = new Imagick($_SERVER['DOCUMENT_ROOT'] . '/' . $this->_name);
where $_SERVER['DOCUMENT_ROOT'].'/'.$this->_name displays :
D:/Sources/my_project/public/media/2/9/1/05201502/55450e1b6543a05201502_9.PNG
I checked that image and it does exist in the folder.
But Imagick throws an exception :
Uncaught exception 'ImagickException' with message 'no decode delegate
for this image format
`D:/Sources/my_project/public/media/2/9/1/05201502/55450b10d8ea705201502_9.PNG'
# error/constitute.c/ReadImage/555' in
D:\Sources\my_project\library\project\Image.php on line 225
I looked for a solution, but didn't find any, how can I fix this?? thank you
Update: This is the result when I type convert -version in the command line :
Version: ImageMagick 6.8.8-4 Q16 x86 2014-01-29 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules OpenMP
Delegates: bzlib cairo freetype jbig jng jp2 jpeg lcms lqr pangocairo \
png ps rsv g tiff webp xml zlib
update
This is the phpinfo of imagick.
ImageMagick number of supported formats: 0
ImageMagick supported formats: no value
Seems that your ImageMagick PHP module does not support any image formats.
Try to find other ImageMagick installation or install PHP from the scratch.
Also - seems that there is already question/answer in SO about that
You should run
convert -version
and report the output. On my system it is
Version: ImageMagick 6.9.0-0 Q16 x86_64 2014-12-06 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules
Delegates (built-in): bzlib cairo djvu fftw fontconfig freetype gslib gvc jbig \
jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png ps \
rsvg tiff webp wmf x xml zlib
Does your output include png as one of the built-in 'delegates'?
If not, update your installation, or build from current sources.
Finally I found solution for my windows openserver/nginx/php-fpm installation:
Download latest php_imagick distributive for your version of PHP from http://windows.php.net/downloads/pecl/releases/imagick/ (e.g. php_imagick-3.4.3-7.1-ts-vc14-x64.zip)
Extract only php_imagick.dll from this archive to your "php/ext" folder.
Run phpinfo() and check value at line "Imagick compiled with ImageMagick version" (mine was: "ImageMagick 6.9.3-7 Q16 x64 ...").
Now go to http://windows.php.net/downloads/pecl/deps/ and download correct version of Imagick-*.zip file (mine was: ImageMagick-6.9.3-7-vc14-x64.zip).
Extact this archive and copy all *.dll files from "/bin" folder to yout "php/ext" folder (about 145 files).
Restart server and check phpinfo(). ImageMagick now supports about 230+ formats.
Sometimes phpinfo() displays that imagick supports all formats, but php scripts are not respond - in this case double check that you download correct version of Imagick-*.zip for your installations. (ts/nts, VC11/VC14, x64/x86)

php5-imagick on Ubuntu 14.04

I've spent quite some time googling for this issue, but to no avail, so I was hoping to get some help out here.
I'm using Ubuntu 14.04 and I've installed php5-imagick, ImageMagick and some extra libs for it to function. Testing the installation from the command line works perfectly and all delegates are installed according to 'convert -list configure' (output shown below).
It was working and performing perfectly before. The only thing I can think of is some system/security updates of Ubuntu. My code nor the IM installation were changed by any user actions before this error showed up.
The problem is when I call Imagick from my PHP script, it shows this error:
#420: no decode delegate for this image format '/' # error/constitute.c/ReadImage/544
This error is shown for both JPG and PNG.
Any help is greatly appreciated!
Output of 'convert -version':
Version: ImageMagick 6.7.7-10 2014-03-06 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP
Output of 'convert -list configure':
DELEGATES bzlib djvu fftw fontconfig freetype jbig jpeg jng jp2 lcms2 lqr lzma openexr pango png rsvg tiff x11 xml wmf zlib
LIBS -lMagickCore -llcms2 -ltiff -lfreetype -ljpeg -llqr-1 -lglib-2.0 -lfftw3 -lfontconfig -lfreetype -lXext -lSM -lICE -lX11 -lXt -llzma -lbz2 -lz -lm -lgomp -lpthread -lltdl
I think the problem here is that Imagemagick isn't configured to support SVG. Installing basic php5-imagick package doesn't bring in some extras which you'll need for doing this.
To install support for SVG in PHP Imagick type the following into a terminal on the server in question:
sudo apt-get update
sudo apt-get install libmagickcore5-extra
Apt will list a load of dependent packages, including SVG libraries, and will ask you if you'd like to continue. Press Y and let it get on with it.
It appears that you're trying to open the file named '/'.
Strangely enough Imagick is not able to open that file.
Try passing in a real image filename.
Check the file to be processed with the vim command. Probably not an image.
I had a similar problem. You can see it here:
ImageMagick on Ubuntu 14.04 No decode delegate

No formats supported in PHP/ImageMagik/imagick

I've installed pecl-imagick from FreeBSD ports and it can't do a thing with images.
phpinfo() reports this:
ImageMagick number of supported formats: 0
ImageMagick supported formats: no value
But ImageMagick installed correctly and show all it's stuff:
$ convert -list configure
...
DELEGATES bzlib fftw fontconfig jpeg jng lzma png zlib
...
What could be wrong and how to fix it?
I found that having an extension for GraphicsMagick (a "better" fork) installed causes that.
If you don't feel how it makes any sense, I'm totally with you.
Did you install PHP from ports? Update your ports and re-install packages.

Categories