Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleaned up jpg->raw #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 27 additions & 14 deletions raw_conversion/jpg_to_raw.scm
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,30 @@
;
; for a list of all procedure used check: help > procedure browser
;
(define (jpg_to_raw in_filename out_filename interleaved?)
(let* ((image (car (gimp-file-load RUN-NONINTERACTIVE in_filename in_filename)))
(drawable (car (gimp-image-get-active-layer image))))
; image-type: RAW_RGB (0), RAW_PLANAR (3)
; palette-type { RAW_PALETTE_RGB (0), RAW_PALETTE_BGR (1) }
(file-raw-save2 RUN-NONINTERACTIVE
image
drawable
out_filename
out_filename
(if interleaved? 0 6)
0)
(gimp-item-delete drawable)
(gimp-image-delete image)))

(define (convert-image in-filename out-filename save . save-args)
(let* ((image (car (gimp-file-load RUN-NONINTERACTIVE out-filename in-filename))))
(drawable (car (gimp-image-get-active-layer image)))
(apply save
(append (list RUN-NONINTERACTIVE image drawable out-filename out-filename)
save-args))
(gimp-item-delete drawable)
(gimp-image-delete image)))


(define +raw-image-rgb+ 0)
(define +raw-image-planar+ 3)

(define +raw-palette-rgb+ 0)
(define +raw-palette-bgr+ 1)

(define (jpg->raw in-filename out-filename interleaved? invert-palette?)
(convert-image
in-filename
out-filename
file-raw-save2
(if interleaved?
+raw-image-rgb+
+raw-image-planar+)
+raw-palette-rgb+))

2 changes: 1 addition & 1 deletion raw_conversion/jpg_to_raw.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
XDG_CONFIG_HOME=$PWD
export XDG_CONFIG_HOME
echo $XDG_CONFIG_HOME
gimp -i -b "(jpg_to_raw \"$1\" \"$2\" #t)" -b '(gimp-quit 0)'
gimp -i -b "(jpg->raw \"$1\" \"$2\" #t)" -b '(gimp-quit 0)'