QUERY_PNG

Syntax | Return Value | Arguments | Keywords | Examples | Version History | See Also

QUERY_PNG is a method of obtaining information about a PNG image file without having to read the file. See QUERY_* Routines for more information.

Syntax

Result = QUERY_PNG ( Filename [, Info] )

Return Value

This routine returns a long with the value of 1 (one) if the query was successful (and the file type was correct) or 0 (zero) on failure.

Arguments

Filename

A scalar string containing the pathname of the PNG file to query.

Info

Returns an anonymous structure containing information about the image in the file. The Info.TYPE field will return the value `PNG'.

Note
See General Query * Routine Info Structures for detailed structure information.

Keywords

None

Examples

Query included in creating RGBA (16-bit/channel) and Color Indexed
(8-bits/channel) image.

PRO ex_query_png 
rgbdata = UINDGEN(4,320,240) 
cidata = BYTSCL(DIST(256)) 
red = indgen(256) 
green = indgen(256) 
blue = indgen(256) 
tempdir = GETENV('IDL_TMPDIR') 
WRITE_PNG, tempdir+'rgb_image.png',rgbdata 
WRITE_PNG, tempdir+'ci_image.png',cidata,red,green,blue 
 
; Query and Read the data: 
names = [tempdir+'rgb_image.png',$ 
         tempdir+'ci_image.png',$ 
         tempdir+'unknown.png'] 
 
FOR i=0,N_ELEMENTS(names)-1 DO BEGIN 
   ok = QUERY_PNG(names[i],s) 
   IF (ok) THEN BEGIN 
   HELP,s,/STRUCTURE 
   IF (s.HAS_PALETTE) THEN BEGIN 
      img = READ_PNG(names[i],rpal,gpal,bpal) 
      HELP,img,rpal,gpal,bpal 
   ENDIF ELSE BEGIN 
      img = READ_PNG(names[i]) 
      HELP,img 
   ENDELSE 
   ENDIF ELSE BEGIN 
      PRINT,names[i],' is not a PNG file' 
   ENDELSE 
ENDFOR 
END 

Version History

5.2

Introduced

See Also

QUERY_* Routines, READ_PNG, WRITE_PNG