You are here

Use 'gimp-file-load' or 'file-*-load'

The 'open-input-file' is actually a Scheme function -- similar to 'fopen' in C -- typically used for reading characters from text files.

If you are opening a graphic file, such as a JPEG, PNG, XCF, etc. then you want to use one of the Procedural DataBase procedures for loading image image files.

The main PDB procedure for doing this is 'gimp-file-load'. This procedure tries to determine the specific filetype (JPEG,PNG, etc) based on the contents of the file, or on its file extension (.jpg, .png, .xcf, et cetera). This usually works fine (I've never had it fail), but if you feel more comfortable then there are separate procedures for loading specific file types. These names of these procedures are all of the form "file-***-load", where *** is the type of file (e.g., 'file-jpeg-load').

(let* ((image (car (gimp-file-load RUN-NONINTERACTIVE "tmp.jpg" "tmp.jpg")))
       (layer (car (gimp-image-get-active-layer image))))
  ;
  ; USE (gimp-display-new image) IF YOU WANT TO SEE THE IMAGE
  ; DO SOME STUFF 
  ;
  )

OR ...

(let* ((image (car (file-jpeg-load RUN-NONINTERACTIVE "tmp.jpg" "tmp.jpg")))
       (layer (car (gimp-image-get-active-layer image))))
  ;
  ; USE (gimp-display-new image) IF YOU WANT TO SEE THE IMAGE
  ; DO SOME STUFF 
  ;
  )
Subscribe to Comments for "Use 'gimp-file-load' or 'file-*-load'"