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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:17:12+00:00 2026-05-30T13:17:12+00:00

I am writing a thumbnailing script, and from what I’ve seen thumbnails tend to

  • 0

I am writing a thumbnailing script, and from what I’ve seen thumbnails tend to look best in the same format as their source. However, the script may be fetching images from the web, so I can’t access the file twice. So is there any way to get the file type other than exif_imagetype and other functions that have to re-open the image? I don’t want to rely on the extension as that can obviously be wrong.

I’m doing the thumbnail processing with GD, so something that uses the handle would be perfect, but I could also use the file’s contents. And yes, I’m aware that GD handles reference uncompressed data, but I’m not sure that they don’t remember what they decompressed from.

  • 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-30T13:17:14+00:00Added an answer on May 30, 2026 at 1:17 pm
    function getImageExt($bytes)
    {
        $hex_bytes = '';
        for ($i = 0; $i < strlen($bytes); $i++)
        {
            $hex_bytes .=  dechex(ord($bytes[$i]));
        }
        if (strncasecmp($hex_bytes,'FFD8',4) === 0) return 'jpg';
        if (strncasecmp($hex_bytes,'474946',6) === 0) return 'gif';
        if (strncasecmp($hex_bytes,'89504e47',8) === 0) return 'png';
        if (strncasecmp($hex_bytes,'424d',4) === 0) return 'bmp';
        return false;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Writing and reading from LocalStorage is working fine from my popup and tab. However,
Writing my first Linq application, and I'm trying to find the best way to
Writing a lexer of .java source files in Java. I have a stream of
Writing a simple example from Odersky's book resulted in the following problem: // AbstractElement.scala
Writing code in PHP, how can I ensure the require_once path of a script
Writing my first JQTouch app. When I go from #login to #home , a
Writing some regex to help process street addresses. However, I'm unsure if regex is
Writing a program in which I need to split strings from a struct linked
Writing a shell script and I want to do something like this: cp myfile.ext
Writing a file utility to strip out all non-ASCII characters from files. I have

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.