What are the differences between a GD and a GD2 image? - php

Reading the documentation for imagegd2(), and imagegd(), I noticed the functions are described, respectively as:
Output GD2 image to browser or file
Output GD image to browser or file
What are a GD2, and a GD image? What are the difference between those image types?

gd is an old c library, gd2 is the updated one. php uses gd2.

Some version of GD generates only PNG, but recent version can ganerate GIF and PNG. Soon GD 1 will be no longer supported in next version of PHP.

Related

Problems with PHP GD library when installing Typo3

When I want to install the CMS TYPO3, following problems get detected:
PHP GD library true color support broken
GD is loaded, but calling imagecreatetruecolor() fails. This must be fixed, TYPO3 CMS won't work well otherwise.
PHP GD library gif support broken
GD is loaded, but calling imagecreatefromgif() fails. This must be fixed, TYPO3 CMS won't work well otherwise.
PHP GD library png support broken
GD is compiled with png support, but calling imagecreatefrompng() fails. Check your environment and fix it, png in GD lib is important for TYPO3 CMS to work properly.
When I search for PHP GD2 in my apache server I can only find GD without the 2 - ist this a problem?
There are also some yellow colored problems - do I also have to fix these?
I had the same problem when running the latest wersion of XAMPP as it include PHP v8.
I installed an older version of XAMPP with php v 7.4.13 and the problem seems gone.

Read EXIF data from HEIC photo using PHP

I want to read the EXIF data from a HEIC photo.
If I run:
<?php
var_dump(exif_read_data("test.heic"));
I get
bool(false)
If I run the Linux tool exiftool test.heic - then I can see all the information that I need is there (location, camera name, etc).
If I run exif_read_data("test.jpg") - then I get data. So I know the syntax I'm using is correct.
I'm using PHP 7.1 and ImageMagick 6.9.4-10 (1684).
print_r(imagick::getVersion());
Array
(
[versionNumber] => 1684
[versionString] => ImageMagick 6.9.4-10 Q16 x86_64 2017-05-23 http://www.imagemagick.org
)
Do I need newer versions? If so, which ones work with HEIC?
This is a limitation in the EXIF extension for PHP. Currently the EXIF extension will only read two file formats:
JPEG
TIFF
As the extension maintainer for EXIF in PHP, I cannot say that there is a specific plan to support more formats, as only recently one report has been posted at the bug tracker in regards to supporting PNG images (starting with version 1.5 of the PNG specification).
My suggestion to you is to report it as a "Feature Request" on the PHP bug tracker so it can be tracked (and if you can provide details or even an experimental implementation, it would help push this into PHP faster). For now the only option is to convert images into JPEG or TIFF to make them readable by the EXIF extension.

How to upgrade the version of php-gd library when running from php-fpm at Ubuntu 16.04 server?

I've followed this tutorial to install and support PHP-5.6 at my ISPConfig3 server: https://www.howtoforge.com/tutorial/how-to-install-php-5-6-on-ubuntu-16-04/.
The installation is up and running, now I want to change the php-gd library version. PHP info actually reports:
GD Support enabled
GD Version bundled (2.1.0 compatible)
I need to use the following version:
GD Support enabled
GD headers Version 2.2.3
GD library Version 2.2.3
Why do i need to upgrade?
I'm facing problems when cropping images, but is only on this server. I've a similar server with PHP-5.6, without fpm, that is working fine. I realized the difference in versions after compare the phpinfo() reports from both servers
Expected Behavior
User uploads an image. The image can have any dimension. (eg: 1920x1080)
The script resizes the image. (eg: from 1920px to 1200px)
The resized image maintain it's original aspect ratio and should not be cropped.
See: http://imgur.com/MkMVg6x
The problem
User uploads an image. The image can have any dimension. (eg: 1920x1080)
The script SHOULD resize the image. (eg: from 1920px to 120px)
The final image was cropped erroneously :(
See: http://imgur.com/a/wT0Rh
Since i'm using php-fpm, how can i upgrade my GD library version?
After long hours digging, I finally found the problem, and as i expected, it's not related to GD library itself. It's related to phpThumb and imagemagick libraries.

imagick not converting webp format on Amazon Linux

imagick convert command is not working for this webp image -
https://lh3.googleusercontent.com/VRY0O_3L8VH2wxJSTiKPr72PeM5uhPPFEsHzzYdxenddpTI150M0TYpljnZisQaROR0=h256-rw -
convert -resize 50x50! https://lh3.googleusercontent.com/VRY0O_3L8VH2wxJSTiKPr72PeM5uhPPFEsHzzYdxenddpTI150M0TYpljnZisQaROR0=h256-rw /var/test_sandeepan/output.jpg
Output -
convert: no decode delegate for this image format `WEBP' # error/constitute.c/ReadImage/535.
From this, I conclude that webp is either not supported by Imagick at all, or not supported by this version.
A link shared in this answer, talks about webp support along with imagemagick and php, so I thought imagick must be supporting webp as well, because PHP imagemagick, as per my understanding is nothing but a wrapper class to the imagick utility. Please correct me if I am wrong here.
I conclude that webp is either not supported by Imagick at all, or not supported by this version.
Imagick doesn't really do anything. All it does is convert PHP function calls into C function calls, to call the ImageMagick code through its 'wand' API.
If you want to have ImageMagick support webp, you will either need to install a version that has been compiled with webp support compiled in, or compile it yourself: http://www.imagemagick.org/script/advanced-unix-installation.php
You'll need to install libwebp-devel either from apt/yum, or from https://github.com/webmproject/libwebp as ImageMagick relies on that 'delegate' code being there to read/write webp images.

Convert SVG to PNG with GD

I want to convert an SVG image to a PNG in PHP. I know how to do it in Imagemagick but I dont get it to work on my Webserver and it seems SVG support is not very good with imagemagick.
So how can I do it with GD and is SVG even supported?
Sadly, GD2 does not support SVG. I had to install a unix virtual machine and I am trying with Imagick, that supports SVG.

Categories