It is currently Mon Apr 15, 2024 8:12 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: file-jpeg-save failed on invalid input arguments
PostPosted: Fri Jul 08, 2011 9:36 pm  (#1) 
Offline
GimpChat Member

Joined: Jul 08, 2011
Posts: 7
I'm trying to write a script to create a thumbnail for a picture and I have a problem.

I've been searching for hours, but I just can't figure out why I always get the error "Procedure execution of file-jpeg-save failed on invalid input arguments".

I use a similar script for cropping dvd covers and I have no problems saving with it, but for some reason, it won't work here.

I tried to manually enter every parameters I could to eliminate a bad variable, but it changed nothing. I even tried the picture I'm using to test it with my other script and it works perfectly so the problem is not the source.

Here's the script(the only parameter is the filename without the .jpg) and I hope someone can figure out what the problem is:
(define (thumb_maker jpegname)
(let* (
(input (string-append "F:/_Photos/" jpegname ".jpg"))
(output (string-append "F:/_Photos/" jpegname "_thumb.jpg"))
(image (car (file-jpeg-load 1 input output)))
(width (car (gimp-image-width image)))
(height (car (gimp-image-height image)))
(q)(r)(x)(y)(drawable)
)

;Set the jpeg quality
(set! q 85)
;Set the new height
(set! y 150)
;Calculate the scale ratio
(set! r (/ height y))
;Calculate the new width
(set! x (trunc (/ width r)))
;Resize the image
(gimp-image-scale image x y)
;Update drawable
(set! drawable (car (gimp-image-get-active-drawable image)))
;Save in jpeg
(file-jpeg-save 1 image drawable output output q 0 1 0 "" 0 1 0 0)))


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: file-jpeg-save failed on invalid input arguments
PostPosted: Fri Jul 08, 2011 10:38 pm  (#2) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
The 'q' parameter should be a value between 0.0 and 1.0 (e.g., 0.85).

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: file-jpeg-save failed on invalid input arguments
PostPosted: Sat Jul 09, 2011 6:41 am  (#3) 
Offline
GimpChat Member

Joined: Jul 08, 2011
Posts: 7
Thank you so much. I knew it had to be something stupid and I guess I'm too used to give a full integer as quality in the gui.

Everything works fine now, thanks again.


Top
 Post subject: Re: file-jpeg-save failed on invalid input arguments
PostPosted: Sat Jul 09, 2011 2:47 pm  (#4) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4734
Just wondering why you don't use ImageMagick for this? For instance, creating a thumb-$n
file for every JPG in the current directory, with a small side of 200 pixels:

convert *.jpg -geometry 200x200^ -set filename:out "thumb-%f" '%[filename:out]'

_________________
Image


Top
 Post subject: Re: file-jpeg-save failed on invalid input arguments
PostPosted: Sat Jul 09, 2011 5:00 pm  (#5) 
Offline
GimpChat Member

Joined: Jul 08, 2011
Posts: 7
ofnuts wrote:
Just wondering why you don't use ImageMagick for this?


Because I like to install as little software as possible and gimp can do the job exactly as I want it to. Like choosing the quality which your example doesn't seem to do. Also, it was important that only the height be fixed, not the width(not sure if your example do this or not, I don't understand it fully).

Also, I like to familiarize myself with script-fu since I find it can be very useful and since I tend to forget things, the more I make scripts the better.


Top
 Post subject: Re: file-jpeg-save failed on invalid input arguments
PostPosted: Sat Jul 09, 2011 6:12 pm  (#6) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4734
ImageMagick has a full range of options, this was only an example. It's one of the best bang for the buck^H^H^H^Hdisk-space around... Not speaking of execution speed.

I'm like you, I find that script are the best way to document things, but they don't have to be script-fu :)

_________________
Image


Top
 Post subject: Re: file-jpeg-save failed on invalid input arguments
PostPosted: Sat Jul 09, 2011 7:19 pm  (#7) 
Offline
GimpChat Member

Joined: Jul 08, 2011
Posts: 7
Maybe I'll try it out if I have free time. For now, gimp is just less trouble since I'm more familiar with it, it's already installed on my many computers and I'm entirely satisfied with it for the little times I use it.


Top
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) loss of ability to save as Jpeg and PNG file type

2

No new posts Where did GIMP save my file, & how do I change default save location

5

No new posts Invalid parameter name dialog status error

4

No new posts Eager to learn to input text in python script (Solved)

2

No new posts How much you'd save with automation

0



* Login  



Powered by phpBB3 © phpBB Group