Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3311088
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:50:09+00:00 2026-05-17T21:50:09+00:00

Im having issue when a user uploads and try’s to crop a PNG or

  • 0

Im having issue when a user uploads and try’s to crop a PNG or transparent image( with .gif)

I am getting:

Warning: imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable error:  in statusUpFunctions.php on line 100

Warning: imagecreatefromjpeg(): 'images/status/photo/1-6.jpg' is not a valid JPEG file in statusUpFunctions.php on line 100

Warning: imagecopyresampled() expects parameter 2 to be resource, boolean given in statusUpFunctions.php on line 114

This may be because of my php crop function:

case 'crop':
 if ($_SERVER['REQUEST_METHOD'] == 'POST')  {

 ini_set('memory_limit', '256M');
  $jpeg_quality = 90;

  $src = "images/status/photo/".$_POST['fname'];
  $img_r = imagecreatefromjpeg($src);

        if($_POST['fixed'] == 0) {
           $targ_w = $_POST['w'];
           $targ_h = $_POST['h'];
        }
        else {
            $targ_h = $_POST['sizeh']; 
   $targ_w = $_POST['sizew']; 
        }

        $dst_r = ImageCreateTrueColor( $targ_w, $targ_h );

  imagecopyresampled($dst_r,$img_r,0,0,$_POST['x'],$_POST['y'],
  $targ_w,$targ_h,$_POST['w'],$_POST['h']);

 $path_thumbs = "images/status/photo";
  $filename = $newfilename;
     $thumb_path = $path_thumbs . '/' . $filename;

  imagejpeg($dst_r,$thumb_path,$jpeg_quality);
}
break;
}

It creates from jpg, cant i make so it creates from gif and png and bmp and so..? and then convert it somehow..

How should this be solved?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T21:50:09+00:00Added an answer on May 17, 2026 at 9:50 pm

    The function imagecreatefromjpeg() creates a generic PHP image object from a jpeg image. You can then do whatever you want with the object.

    imagecreatefromjpeg() will ONLY create a generic image object FROM a JPEG. If you want to create a generic image object FROM a PNG or GIF, you need to use their respective functions: imagecreatefrompng() and imagecreatefromgif(). One quick way to detect an image’s type is by reading its file extension.

    Once you have that generic image object, then you can do what you want with it (including using imagecopyresampled()), and then create a jpeg image from it using imagejpeg().

    EDIT:

    You can use pathinfo() to detect the file’s extension:

    $filename = pathinfo($_POST['fname']); // Returns an array of file details
    $extension = $filename['extension'];
    

    If you are getting the filename from a $_POST value, you need to make sure that you are copying the temporary image file to that filename. I don’t see any $_FILES values used in your code (maybe you’re doing it in another script?). If not, here’s a good tutorial on handling file uploads. It also covers file extensions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to Windows forms and having an issue handling all the user
I'm having an issue with blobstore uploads, but because of the way gae handles
I'm having an issue properly detecting my user agent against a string of agents,
I'm having a trouble reproducing an issue a user is having in IE, but
I'm having an issue where I have made a user control with two content
I'm having an issue with article Tags where a user can write an article
I'm having a minor issue: When the user edits any article in the front-end
I'm having an issue with the following situation. User visits site User clicks link
I'm having an issue referencing public procedures of User Controls that I've created within
I am having issues populating a List of User defined object attributes in Struts2.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.