Previous IDL Reference Guide: Procedures and Functions Next

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.

rgbdata = UINDGEN(4,320,240)  
cidata = BYTSCL(DIST(256))  
red = indgen(256)  
green = indgen(256)  
blue = indgen(256)  
WRITE_PNG,'rgb_image.png',rgbdata  
WRITE_PNG,'ci_image.png',cidata,red,green,blue  
  
; Query and Read the data:  
names = ['rgb_image.png','ci_image.png','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

  IDL Online Help (March 06, 2007)