2

I found this function on stackoverflow which is :

imagepng(imagecreatefromstring(file_get_contents($filename)), "output.png");

I thought it would fit my needs since it renames/change path/convert to png at the same time, but it doesn't exactly convert the image, it creates a "png copy". I would like the old jpg/gif/jped/png image to be erased aswell.

Is there a way I can add that to this "one-line converting function" ?

Thanks a lot !

Community
  • 1
  • 1
QiMath
  • 455
  • 2
  • 7
  • 18

1 Answers1

0

You're doing a lot in one line:

Read the file:

$file = file_get_contents($filename);

create image object from the contents:

$image = imagecreatefromstring($file);

create png from image object

imagepng($image, "output.png");

You should check these steps to find where the issue is.

My guess? You're missing write permissions on the folder you're writing to.

MNOor
  • 36
  • 1
  • 4
  • Thank you for your answer. Your guess was indeed right it was a permissions issues. I actually was able to fix that and was editing my post accordingly to represent the issue I am facing now (instead of creating another subject for the same function) when you posted this :) – QiMath Sep 11 '16 at 12:06