Jump to content

Recommended Posts

Hi,

I am trying to create a mobile version of my already uploaded file using below code but getting this error

imagecreatefrompng(): is not a valid PNG file

Here is the code:

if (move_uploaded_file($_FILES['photo']['tmp_name'], $uploadedFile))
{
    $resource = imagecreatefrompng($uploadedFile);

    $small_file = imagescale($resource , 500, 400);
    $small_file = imagepng($small_file);

    $newSmallFile = "mobile-" . $gallery_uuid . '.png';
    $uploadedSmallFile = $uploaddir . $newSmallFile;

    echo $uploadedSmallFile;
    
    if (move_uploaded_file($small_file, $uploadedSmallFile))
    {
        
    }
    else
    {
        echo json_encode("error");
    }
}
else
{
    echo json_encode("error");
}

 

Kindly help..

 

Thanks,

Jassim

 

Edited by requinix
removing link

I am getting the following:

IMAGE INTO START HERE ///// Array

(

[

0

] => 1600

[

1

] => 900

[

2

] => 2

[

3

] => width="1600" height="900"

[bits

] => 8

[channels

] => 3

[mime

] => image/jpeg

)

///// IMAGE INTO END HERE<br />

 

the original file is a JPG but I copying it as PNG to standarize it so the file on my FTP after moving is a PNG

 

The clue is in the function name.

imagecreatefrompng() is for creating GD images from a PNG file.

Check the manual and see if can find a similar function that might be suitable for reading a jpg file.

Once you have created the image, you can then output it as a png file.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.