Question

Updating gd / libpng for PHP

I followed the directions for LAMP installation. The code I’m using requires the GD module for PHP, which I installed. The code works as expected on my XAMPP localhost, but not on the live droplet. After a little digging around, my drop is running PHP 7.0.22, with GD Headers/Library version 2.1.1 and libPNG version 1.2.54. My local XAMPP is running PHP 5.6.28 with GD Version “bundled 2.1.0 compatable” with libPNG version 1.5.26. I’m assuming the version difference is the problem, as the same code works as intended on another webhost. I’d like to keep everything together, though,

I have two questions – before I installed the GD module, the code just wouldn’t create the file at all, so I thought perhaps I had folder permissions set wrong so that it couldn’t ‘write’ the file to the directory. What should folder permissions be set to so PHP can open a .png, crop it, then save it to a subfolder? I don’t know if setting those wrong opens up a door for something nefarious. This is a very low-traffic, one-day event, but I wanna do it right still.

Secondly, I think I need to update PHP’s libPNG module, and this is where I’m totally lost. I haven’t worked with Linux before, nor had to manually install PHP etc. – I was setting up an RTMP server for a Twitch marathon next month and it took me 20 minutes to find the /usr folder 'cause I thought the root folder was the “/” folder. So I’m not quite sure how to fix the issue. I think I need to update PHP’s libPNG libraries, and if I saw the command lines I have to put in I could understand them, but I don’t know what to download or what to go sudo apt-get.

I found a home page for libPNG but even if I found a download there, I wouldn’t know what to do with it. I don’t want to install libPNG to the server, I want to install it in a place where PHP will use it.

I think?


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi @MyOyMyke,

Usually the libPNG version and the PHP GD library version are automatically picked up depending on your OS, in your case Ubuntu. If you are using Ubuntu 18.04 it should use a higher version of GD even if the PHP version is actually the same as the one on 16.04.

Now, if you have a Ubuntu 16.04 for instance and you want to use a higher version of libPNG, let’s say libPNG 1.6, you’ll need to download it. You can do so by

sudo apt install linpng16-16

respectively. If you need the development versions (with header files), use libpng16-dev. Libraries installed through apt are installed system-wide.

You can check your linbPNG version afterwards by doing so

dpkg-query --list 'libpng*' | grep '^ii'

You should see something like the following output

ii  libpng16-16:amd64 1.6.34-1ubuntu0.18.04.2 amd64        PNG library - runtime (version 1.6)

Regards, KDSys