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

  • SEARCH
  • Home
  • 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 7724561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:43:13+00:00 2026-06-01T04:43:13+00:00

This is the thumnbail script I’m working on and it ends up creating a

  • 0

This is the thumnbail script I’m working on and it ends up creating a corrupt 33 byte image. I think the problem is in the exif_imagetype if statement but I’m not sure. I would appreciate any help.

    // Original image
    $filename = 'images/T' . $neutralName;

    // Get dimensions of the original image
    list($current_width, $current_height) = getimagesize($filename);

    // The x and y coordinates on the original image where we
    // will begin cropping the image
    $left = 10;
    $top = 5;

    // This will be the final size of the image (e.g. how many pixels
    // left and down we will be going)
    $crop_width = 140;
    $crop_height = 100;

    // Resample the image
    $canvas = imagecreatetruecolor($crop_width, $crop_height);
    if ((exif_imagetype($_FILES['photo']['tmp_name'])) == IMAGETYPE_JPEG) {
        $current_image = imagecreatefromjpeg($filename);
        imagecopy($canvas, $current_image, 0, 0, $left, $top, $current_width, $current_height);
        imagejpeg($canvas, $filename, 100);
    } else if ((exif_imagetype($_FILES["photo"]['tmp_name'])) == IMAGETYPE_GIF) {
        $current_image = imagecreatefromgif($filename);
        imagecopy($canvas, $current_image, 0, 0, $left, $top, $current_width, $current_height);
        imagegif($canvas, $filename, 100);
    } else {
        $current_image = imagecreatefrompng($filename);
        imagecopy($canvas, $current_image, 0, 0, $left, $top, $current_width, $current_height);
        imagepng($canvas, $filename, 100);
    }
  • 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-06-01T04:43:14+00:00Added an answer on June 1, 2026 at 4:43 am

    I think your problem is you’re trying to open an image that doesn’t exist or isn’t an image… In each of your each, you’re finding the file type via $_FILES["photo"]['tmp_name'] but directly below that if the condition is true, you’re using imagecreatefromXXX($filename). Shouldn’t you be opening the image file that was uploaded and not the path to which you’re saving the image? Opening the path $filename (assuming it exists) would always copy the same exact square and save it. Doesn’t seem like a viable thing you’d be doing.

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

Sidebar

Related Questions

I found this script online that creates a thumbnail out of a image but
I have this script at the moment, which changes an image when a thumbnail
I have a working script like this: jQuery(document).ready(function(){ $('.video-thumb img').bind('mouseover',function(){ var new = $(this).attr('src').replace(/default.jpg/,'1.jpg');
This is probably quite straight-forward but at the moment I can't think of a
I'm currently working on a PHP/MySQL script that does the following, in this order:
know nothing about php, but I have this script that reads a folder and
I am writing a simple image replacement script on a site I am working
I have the following script (it looks long, but well commented). Problem is, i
This is driving me crazy, so... When resizing image to small thumbnail, resulting image
I want to display a thumbnail image in a cell of tableViewController , this

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.