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 816523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:50:43+00:00 2026-05-15T01:50:43+00:00

to those that may have read my previous question that got solved a couple

  • 0

to those that may have read my previous question that got solved a couple minutes ago >.<

The on-the-fly php script works perfectly, but when I went to upload new images into a gallery which I made myself, the images are resized to 150 x 150 for what I wanted… however, when it comes to new images being added it is all black…

alt text

As you can see the three black images that were uploaded to the folder and the directory added to the database.

The other (non-black images) are already resized with image.php.

What is causing this?

If I view the source, the code is fine… the while loop in the PHP generates an output like this:

<div class="view-wrap" id="photo-10">
    <div class="view-icon">
        <div class="img-label">
            <a href="#" id="10" class="delete"><img src="img/small-delete.png" /> Delete</a>
        </div>

        <a href="img/events/Paintballing/24251_1395408043148_1170626626_1204038_5382765_n.jpg">
            <img src="image.php?dir=img/events/Paintballing/24251_1395408043148_1170626626_1204038_5382765_n.jpg" alt="" width="110" height="110" />
        </a>
    </div>
</div>

An example of one block.

If I view the source (in Firefox) and click on the image.php?dir=img/events/Paintballing/24251_1395408043148_1170626626_1204038_5382765_n.jpg by exmaple, I can see the thumbnail at it’s 150 x 150 size but in the layout, it shows a black thumbnail…

Does anyone know why this is happening?

EDIT:

<?php 

$dir = $_GET['dir'];

header('Content-type: image/jpeg'); 

$create = imagecreatetruecolor(150, 150); 

$img = imagecreatefromjpeg($dir);

list($width, $height) = getimagesize($dir);

imagecopyresampled($create, $img, 0, 0, 0, 0, 150, 150, $width, $height);

imagejpeg($create, null, 100); 

?>

This is image.php.

  • 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-15T01:50:44+00:00Added an answer on May 15, 2026 at 1:50 am

    Thanks for updating your post.

    Are you positive that the image is a jpg/jpeg that your uploading.

    Try changing to the following

    <?php 
    
    $dir = $_GET['dir'];
    $ext = strtoupper(pathinfo($dir, PATHINFO_EXTENSION));
    switch($ext)
    {
        case 'jpeg':
        case 'jpg':
            $img = imagecreatefromjpeg($dir);
        break;
        case 'png':
            $img = imagecreatefrompng($dir);
        break;
        case 'gif':
            $img = imagecreatefromgif($dir);
        break;
    }
    if(isset(img))
    {
        header('Content-type: image/jpeg'); 
        $create = imagecreatetruecolor(150, 150); 
        list($width, $height) = getimagesize($dir);
        imagecopyresampled($create, $img, 0, 0, 0, 0, 150, 150, $width, $height);
        imagejpeg($create, null, 100); 
    }else
    {
       echo sprintf('Unable to process image, Unknown format %s',$ext);
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is one of those meta-programming questions that may or may not belong on
I have a few classes, such as those that outline database table structure or
I'm starting to learn Python and I've come across generator functions, those that have
It's one of those things that seems to have an odd curve where the
I have a table with doctor offices and doctors in those offices that I'm
I really have read the other articles that cover this subject. But I seem
Here's a coding problem for those that like this kind of thing. Let's see
I'm looking for a regular expression that will match all strings EXCEPT those that
I'm using Emma in my ant build to perform coverage reporting. For those that
You know those websites that let you type in your checking account number and

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.