473,480 Members | 2,266 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

check image bit-depth without an image library

dlite922
1,584 Recognized Expert Top Contributor
Hey guys,

I have limited access to a server and would be a pain to install and configure an image library such as GD or Imagick with PHP.

Is there any other progmatically some-what reliable way to check the bit-depth of a png or jpg image? (e.g. 16-bit, 32-bit, 64-bit)

This of course, means opening up the file and taking a peek inside, but the files look different.

There's no such thing as a bad idea, just untried ones, so fire away!





Dan

EDIT: Can somebody post what JPEG Analyzer does? (limited google access), thanks.
Mar 31 '09 #1
3 4497
Amzul
130 New Member
umm maybe you can try to fopen the file then read line by line and search for png structure

fopen with binary read flag maybe
Mar 31 '09 #2
dlite922
1,584 Recognized Expert Top Contributor
@Amzul
Ya, I tried this, my images weren't consistent and I didn't see a pattern.

some have JFIF header info, some don't.

As a temporary solution I used imagick CLI: "identify -verbose"
If there is an alpha channel, I return 32, else if Pallete type, its 8 bit, else if TrueColor return 24 bit. else -1.

I tested it with the three bit-depth and seems to work enough.

I also tried getimagesize() which gives you a "bits" value, but it was always 8 for all of the above image depth and returned 1 for an image who was just all FF0000.

my files are 100% PNG.





Dan
Apr 1 '09 #3
hsriat
1,654 Recognized Expert Top Contributor
Did you try to do some mathematical calculations with the number of bits each 'row of pixels' contain and the length after which 'end of row bit pattern' repeats?
Apr 10 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

27
2564
by: John Roth | last post by:
PEP 263 is marked finished in the PEP index, however I haven't seen the specified Phase 2 in the list of changes for 2.4 which is when I expected it. Did phase 2 get cancelled, or is it just not...
2
7151
by: Doug Baroter | last post by:
Hi, DDLs and DMLs: create table #job (jobID int identity(1,1) primary key, jobName varchar(25) unique not null, jobEndDate dateTime, jobComplete bit default(0), check (( is null and = 0) OR (...
8
4415
by: Siemel Naran | last post by:
Hi. How to check if a bit is off? To check if a bit is on we do return d_flags & flag; where flag is one flag. To check if a bit is off would this work? return ~d_flags & flag;
5
2338
by: A.Dagostino | last post by:
hi i need to update an SQL Table when user select or unselect a checkbox control. How Can i do? Thanks Alex
2
2639
by: CSharp | last post by:
Is it possible to find if lower 1st bit and 2nd bit in an 32-bit integer is set using regular expression in C# Example 1. Input Strings - 0, 1, 2 Result - Fai 2. Input Strings - 3, 7, ...
9
2480
by: RJ | last post by:
Hi All, Suppose i have a double pointer, how do I check the content of that pointer is a 8/16/24/32 bit data? Any suggestion!! Thanks, Raja
6
50237
by: Klaas Vantournhout | last post by:
Hi, I have a question, which is just out of interest. What is the fastest way to do an odd/even check with c++ and if needed assembler. Assume n is an unsigned integer like type (unsigned...
7
2859
by: geliangwei | last post by:
The 32-bit float number is defined by IEEE 754. Given a float variable, f, how to check whether each of the 32 bits is '1' or '0'? One possible solution is access f as a 32-bit int. That is...
173
7926
by: Marty James | last post by:
Howdy, I was reflecting recently on malloc. Obviously, for tiny allocations like 20 bytes to strcpy a filename or something, there's no point putting in a check on the return value of malloc....
14
11055
by: dissectcode | last post by:
Hi everyone - I was reading in the K&R C book (on page 150) that (Bit) Fields are assigned left to right on some machines and right to left on others. This means listing the bit fields from most...
0
7049
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6912
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6744
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
6981
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5348
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4790
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4488
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2989
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
565
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.