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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:36:04+00:00 2026-05-31T01:36:04+00:00

UPDATE: For anyone else wondering about this, check out the comment at http://www.php.net/manual/en/function.imagecreatefromstring.php#31178 I

  • 0

UPDATE: For anyone else wondering about this, check out the comment at http://www.php.net/manual/en/function.imagecreatefromstring.php#31178

I have images stored in a database table. They’re uploaded in their original dimensions.
I can output this image to browser using PHP headers no problem (like “getimage.php?imgID=1”), but I’m stuck if I want to resize the image before it’s output to the browser.

I do not want to write to a new file, I just want to get an image from the database table, and resize it (preferably in the same PHP script).

Something like this would be perfect: getimage.php?imgID=1&width=75&height=75

Can anyone tell me how I could do this in PHP?

    $query=  "select * from `tablename`.`photos` where `ImageID` = '".$_GET['imgID']."' LIMIT 1";
$downloadResult = SendQuery("browse",$query); // my own custom php function to connect & send a mysql query
if(is_array($downloadResult)){ //check if a row was returned
    foreach($downloadResult as $myfile) {
        header("Content-Type: ". $myfile['mime']);
        header("Content-Length: ". $myfile['size']);
        if($d=="true"){
        header('Content-Disposition: inline; filename="'. urlencode($myfile['name']).'"');  
        }
        echo $myfile['data'];
    }
  • 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-31T01:36:06+00:00Added an answer on May 31, 2026 at 1:36 am

    You load the image data from a binary string ($myfile['data']). All you need is an image library/extension that is able to create an image object based on a binary string. For example the GD library can load data from strings:

    $im = imagecreatefromstring($myfile['data']);
    

    You can then take any of the very many examples (including tons of them on this site already) to resize your image to your needs.

    After you have resized your image, you can output it to the browser, e.g this for a PNG:

    imagepng($im);
    imagedestroy($im);
    

    See imagecreatefromstring­Docs. You might find it helpful if you use a image library that does resizing with an easy interface, for example Wideimage which supports loading from a binary string as well. It’s GD based:

    WideImage::loadFromString($myfile['data'])
        ->resize(50, 30)
        ->output('png');
    

    Yes, it’s that simple. See:

    • Loading images
    • Manipulating images
    • Saving images
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Has anyone else out there had this problem and found a possible solution. Im
Has anyone tried out working with the Delete and update command of SPDataSource used
I need to update jquery1.3.2 to jquery1.4 (in Asp.net MVC). Please can anyone tell
I think the question is pretty self explanatory. Anyone done this before? UPDATE :
I was wondering if anyone else ran into the problem where jQuery scripts such
Hi guys I was wondering if anyone could help me out, I need to
I'm just wondering if anyone else has had problems moving the Zend Framework from
Can someone please check out this code, i really dont understand why i got
I am wondering if this is possible at all. I want to update column
I am wondering if anyone else has had an issue with running the DB

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.