/usr/share/gnudatalanguage/lib/read_image.pro is in libgnudatalanguage0 0.9.7-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | ;+
;
; NAME: READ_IMAGE
;
; PURPOSE: Reads a image file (and colors tables) into memory
;
; CATEGORY: Images (IO)
;
; CALLING SEQUENCE:
; READ_JPEG, filename, red, green, blue, image_index=image_index, $
; help=help, test=test
;
; KEYWORD PARAMETERS:
; UNIT: not supported yet
; BUFFER: not supported yet
; COLORS: Number of colors to dither to (8->256)
; DITHER: Method of dithering to use
; GRAYSCALE: Return a grayscale image
; ORDER: flip the image in the vertical
; TRUE: Interleaving (1:pixel, 2:line, 3:band)
; TWO_PASS_QUANTIZE: Not supported yet
;
; OUTPUTS: [n,m], [2,n,m], [3,n,m], [4,n,m] following image properties
; (transparency adds one extra Dim)
;
; OPTIONAL OUTPUTS: For pseudocolor only: Red, Green, Blue
;
; SIDE EFFECTS:
;
; RESTRICTIONS:
; Requires ImageMagick (that means that GDL must have been
; compiled with ImageMagick)
;
; PROCEDURE:
; Use ImageMagick to read the data as requested
;
; EXAMPLE: An image of Saturn should be around in the GDL CVS
;
; file=FILE_WHICH('Saturn.jpg')
; image=READ_IMAGE(file, image)
; TV, image, /true
;
; MODIFICATION HISTORY:
; Initial version written by: Alain Coulais, 2012-02-15
; 2012-Feb-12, Alain Coulais :
;
;-
; LICENCE:
; Copyright (C) 2012
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
;-
;
function READ_IMAGE, filename, red, green, blue, $
image_index=image_index, $
help=help, test=test
;
ON_ERROR, 2
;
; this line allows to compile also in IDL ...
FORWARD_FUNCTION MAGICK_EXISTS, MAGICK_PING, MAGICK_READ
;
if KEYWORD_SET(help) then begin
print, 'function READ_IMAGE, filename, red, green, blue, $'
print, ' image_index=image_index, $'
print, ' help=help, test=test'
return, -1
endif
;
; Do we have access to ImageMagick functionnalities ??
;
if (MAGICK_EXISTS() EQ 0) then begin
MESSAGE, /continue, "GDL was compiled without ImageMagick support."
MESSAGE, "You must have ImageMagick support to use this functionaly."
endif
;
if ((N_PARAMS() EQ 0) OR (N_PARAMS() GT 4)) then $
MESSAGE, "Incorrect number of arguments."
;
if (N_ELEMENTS(filename) GT 1) then MESSAGE, "Only one file at once !"
if (STRLEN(filename) EQ 0) then MESSAGE, "Null filename not allowed."
if ((FILE_INFO(filename)).exists EQ 0) then MESSAGE, "Error opening file. File: "+filename
if (FILE_TEST(filename, /regular) EQ 0) then MESSAGE, "Not a regular File: "+filename
;
; First, we have to test whether the file is here
;
status=QUERY_IMAGE(filename, info)
;
if (status EQ 0) then begin
MESSAGE, 'Not a valid image file: '+filename
endif
;
case info.type of
'JPEG' : begin
if (info.has_palette EQ 1) then begin
READ_JPEG, filename, image, colortable, colors=256
red=REFORM(colortable[*,0])
green=REFORM(colortable[*,1])
blue=REFORM(colortable[*,2])
endif else begin
READ_JPEG, filename, image
endelse
end
'PNG' : READ_PNG, filename, image, red, green, blue
'GIF' : READ_GIF, filename, image, red, green, blue
else: MESSAGE, 'This format is not managed today, please contribute'
endcase
;
if KEYWORD_SET(test) then STOP
;
return, image
;
end
|