It is currently Mon Apr 15, 2024 7:55 am


All times are UTC - 5 hours [ DST ]


Switch to mobile style

Post new topic Reply to topic  [ 35 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Help to use liquid resize in batch (or with a script )
PostPosted: Mon Feb 20, 2012 4:59 pm  (#21) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14709
Location: USA
Thanks MareroQ.

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
 Post subject: Re: Help to use liquid resize in batch (or with a script )
PostPosted: Mon Feb 20, 2012 7:15 pm  (#22) 
Offline
GimpChat Member

Joined: Apr 12, 2010
Posts: 5870
thank you !

_________________
My 3D Gallery on Deviantart http://photocomix2.deviantart.com/
Main gallery http://www.flickriver.com/photos/photocomix-mandala/
Mandala and simmetry http://www.flickriver.com/photos/photocomix_mandala/

Image

Mrs Wilbress


Top
 Post subject: Re: Help to use liquid resize in batch (or with a script )
PostPosted: Mon Feb 20, 2012 11:10 pm  (#23) 
Offline
Script Coder
User avatar

Joined: Feb 18, 2011
Posts: 4827
Location: Bendigo Vic. Australia
The script works well I just was wondering about this part of the request though

all saved in a new "Wallpaper" subfolder inside the original directory (if was C:/...Pictures/Lysergica will be saved in C:/...Pictures/Lysergica/wallpaper

Does anyone have any thoughts in python or script-fu

I decide to post a script-fu version that allows you to change the output size.

Attachment:
Resize image.scm [1.31 KiB]
Downloaded 96 times

_________________
Image
No matter how much you push the envelope, it'll still be stationery.


Top
 Post subject: Re: Help to use liquid resize in batch (or with a script )
PostPosted: Tue Feb 21, 2012 5:22 am  (#24) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
I realise that the creators of the plugin don't communicate this at all, but the installer also installs scripts for doing batch processing using the plugin:

batch-gimp-lqr
batch-gimp-lqr-full
batch-gimp-lqr-full-use-id
Which are in the file C:\Program Files\GIMP-2.0\share\gimp\2.0\scripts\batch-gimp-lqr.scm

As for saving the results in a different directory, I did that in this simple script:
http://gimpforums.com/thread-batch-desp ... 37#pid8937

Kevin


Top
 Post subject: Re: Help to use liquid resize in batch (or with a script )
PostPosted: Tue Feb 21, 2012 5:31 pm  (#25) 
Offline
Script Coder
User avatar

Joined: Feb 18, 2011
Posts: 4827
Location: Bendigo Vic. Australia
Kevin I'll have a look at this, as I'm not very good at this Part of things. but I'm willing to learn

_________________
Image
No matter how much you push the envelope, it'll still be stationery.


Top
 Post subject: Re: Help to use liquid resize in batch (or with a script )
PostPosted: Wed Feb 22, 2012 1:12 am  (#26) 
Offline
Script Coder
User avatar

Joined: Feb 18, 2011
Posts: 4827
Location: Bendigo Vic. Australia
This is my script unfortunately it replaces the existing image with the new image and I need help to change it so that it saves as a different filename

(define (script-fu-resize-image image drawable
                                      out-width
                                      out-height)
                      

(let* (
            (image-layer (car (gimp-image-get-active-layer image)))
         (width (car (gimp-image-width image)))
         (height (car (gimp-image-height image)))
            (dupImage 0)
         (dup-layer 0)         
            (shortname (car (gimp-image-get-name image)))
            (fullname (car (gimp-image-get-filename image)))
         (handler (car (gimp-message-get-handler)))
         
      )   
   (gimp-context-push)
    (gimp-image-undo-group-start image)
   (gimp-context-set-foreground '(0 0 0))
   (gimp-context-set-background '(255 255 255))


;;;; Create a copy of the image
   (set! dupImage (car (gimp-image-duplicate image)))
   (set! dup-layer (car (gimp-image-merge-visible-layers dupImage EXPAND-AS-NECESSARY)))
   
   (plug-in-lqr 1 dupImage dup-layer out-width out-height 0 0 0 0 0.0 0 0 0.0 0 TRUE 0 0 0 0 0 0 0 0 "" "" "" "")
   
   

;;;;save file as png
      (gimp-progress-set-text (string-append "Saving: " (string-append shortname ".png")))
      (file-apng-save-defaults RUN-NONINTERACTIVE dupImage (car (gimp-image-get-active-drawable dupImage))
                      (string-append fullname)
                      (string-append shortname))       
   

If I could get an assist I would be delighted (tried all day but nothing has worked)

_________________
Image
No matter how much you push the envelope, it'll still be stationery.


Top
 Post subject: Re: Help to use liquid resize in batch (or with a script )
PostPosted: Wed Feb 22, 2012 1:24 pm  (#27) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2238
Location: Poland
This is a very interesting problem (need help of experts - how to apply for different sizes)
Looking for a solution (for python) - another way
Somehow, the solution - can be adapted win_iconizer_1_0.py (Marco Crippa) http://krypt77.altervista.org/
Need help of expert consultants (I'm in this regard in the nursery...)


Attachments:
Win-Iconizer.png
Win-Iconizer.png [ 14.46 KiB | Viewed 1162 times ]
Win-Resizer.png
Win-Resizer.png [ 12.6 KiB | Viewed 1162 times ]

_________________
Image

Slava
Ukraini!
Top
 Post subject: Re: Help to use liquid resize in batch (or with a script )
PostPosted: Wed Feb 22, 2012 4:25 pm  (#28) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14709
Location: USA
Can you try saving the new image as a temp image file?
I am not sure what the PDB call would be. Something like Robs Shellout temp file i imagine.

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
 Post subject: Re: Help to use liquid resize in batch (or with a script )
PostPosted: Wed Feb 22, 2012 5:49 pm  (#29) 
Offline
Script Coder
User avatar

Joined: Jul 14, 2010
Posts: 697
@Graechan -

Try something like:

            (shortname (string-append (unbreakupstr (butlast (strbreakup (car (gimp-image-get-name image)) ".")) ".") "-" (number->string out-width) "x" (number->string out-height) ".png"))
            (fullname (string-append (unbreakupstr (butlast (strbreakup (car (gimp-image-get-filename image)) ".")) ".") "-" (number->string out-width) "x" (number->string out-height) ".png"))


This should save the image as "originalfilename-WxH.png" where W is the width passed in and H is the height passed in.

(and you don't need the two string-appends in the save call)

-Rob A>

_________________
Image
Fantasy Cartography and Mapping by RobA


Top
 Post subject: Re: Help to use liquid resize in batch (or with a script )
PostPosted: Fri Feb 24, 2012 8:54 pm  (#30) 
Offline
Script Coder
User avatar

Joined: Feb 18, 2011
Posts: 4827
Location: Bendigo Vic. Australia
RobA wrote:
@Graechan -

Try something like:

            (shortname (string-append (unbreakupstr (butlast (strbreakup (car (gimp-image-get-name image)) ".")) ".") "-" (number->string out-width) "x" (number->string out-height) ".png"))
            (fullname (string-append (unbreakupstr (butlast (strbreakup (car (gimp-image-get-filename image)) ".")) ".") "-" (number->string out-width) "x" (number->string out-height) ".png"))


This should save the image as "originalfilename-WxH.png" where W is the width passed in and H is the height passed in.

(and you don't need the two string-appends in the save call)

-Rob A>

Thankyou Rob A . I finally got it working with persevierance by changing the save call to this.

(file-apng-save-defaults RUN-NONINTERACTIVE dupImage (car (gimp-image-get-active-drawable dupImage))
                      (string-append fullname(number->string out-width) "X" (number->string out-height) ".png")
                      (string-append shortname(number->string out-width) "X" (number->string out-height) ".png"))

But it is sloppy and saves the image as (pirates.png1920X1200.png) where as doing it as you suggested saves the image as (pirates-1920x1200.png) much nicer, I could not get rid of the first ".png" in mine. I will post the Script for Photocomix tomorrow :yes :bigthup :hi5

_________________
Image
No matter how much you push the envelope, it'll still be stationery.


Top
 Post subject: Re: Help to use liquid resize in batch (or with a script )
PostPosted: Sat Feb 25, 2012 11:49 am  (#31) 
Offline
Script Coder
User avatar

Joined: Jul 14, 2010
Posts: 697
Graechan wrote:
Thankyou Rob A . I finally got it working with persevierance by changing the save call to this.

(file-apng-save-defaults RUN-NONINTERACTIVE dupImage (car (gimp-image-get-active-drawable dupImage))
                      (string-append fullname(number->string out-width) "X" (number->string out-height) ".png")
                      (string-append shortname(number->string out-width) "X" (number->string out-height) ".png"))

But it is sloppy and saves the image as (pirates.png1920X1200.png) where as doing it as you suggested saves the image as (pirates-1920x1200.png) much nicer, I could not get rid of the first ".png" in mine. I will post the Script for Photocomix tomorrow :yes :bigthup :hi5


Yeah - that's what the (unbreakupstr (butlast (strbreakup stuff does... breaks the string up into a list of strings using the "." as a delimter, takes all of the list but the last one (butlast is kind the reverse of cdr) then recombines them back into a string putting the "." back in with the unbreakupstr.

I found that cleverness in one of SaulGoode's scripts and have been using it ever since....

-Rob A>

_________________
Image
Fantasy Cartography and Mapping by RobA


Top
 Post subject: Re: Help to use liquid resize in batch (or with a script )
PostPosted: Sat Feb 25, 2012 6:45 pm  (#32) 
Offline
GimpChat Member

Joined: Apr 12, 2010
Posts: 5870
Graechan wrote:
I will post the Script for Photocomix tomorrow :yes :bigthup :hi5



WOW ! :jumpclap :jumpclap :jumpclap :hi5 :yes
:clap

_________________
My 3D Gallery on Deviantart http://photocomix2.deviantart.com/
Main gallery http://www.flickriver.com/photos/photocomix-mandala/
Mandala and simmetry http://www.flickriver.com/photos/photocomix_mandala/

Image

Mrs Wilbress


Top
 Post subject: Re: Help to use liquid resize in batch (or with a script )
PostPosted: Sun Feb 26, 2012 1:14 am  (#33) 
Offline
Script Coder
User avatar

Joined: Feb 18, 2011
Posts: 4827
Location: Bendigo Vic. Australia
The Image 1000 x 1000

Image

Resized to 1920 x 1200

Image

Resized to 600 x 600

Image

This is the script so far, Downsizing it's a bit iffy with the image I used. but that looks better using Scale option instead of liquid Rescale.

(define (script-fu-resize-and-save-image image drawable
                                      out-width
                                      out-height
                             method
                             savepng
                             savejpg)
                      

(let* (
            (image-layer (car (gimp-image-get-active-layer image)))
         (width (car (gimp-image-width image)))
         (height (car (gimp-image-height image)))
            (dupImage 0)
         (dup-layer 0)         
            (shortname (string-append (unbreakupstr (butlast (strbreakup (car (gimp-image-get-name image)) ".")) ".") "-" (number->string out-width) "x" (number->string out-height)))
         (fullname (string-append (unbreakupstr (butlast (strbreakup (car (gimp-image-get-filename image)) ".")) ".") "-" (number->string out-width) "x" (number->string out-height)))
         ;(handler (car (gimp-message-get-handler)))
         
      )   
   (gimp-context-push)
    (gimp-image-undo-group-start image)
   (gimp-context-set-foreground '(0 0 0))
   (gimp-context-set-background '(255 255 255))


;;;; Create a copy of the image
   (set! dupImage (car (gimp-image-duplicate image)))
   (set! dup-layer (car (gimp-image-merge-visible-layers dupImage EXPAND-AS-NECESSARY)))
   
   (if (= method 1) (gimp-image-scale-full dupImage out-width out-height 2))
   
   (if (= method 0) (plug-in-lqr 1 dupImage dup-layer out-width out-height 0 1000 0 1000 0 0 1 100 1 1 0 0 3 0 0 0 0 1 "" "" "" ""))


       
(if(= savepng TRUE)
   (begin
;;;;save file as png
      (gimp-progress-set-text (string-append "Saving: " (string-append shortname ".png")))
      (gimp-file-save 1 dupImage dup-layer (string-append fullname ".png") (string-append shortname ".png"))
   )
)
               
(if(= savejpg TRUE)
   (begin
;;;;save file as jpg
      (gimp-progress-set-text (string-append "Saving: " (string-append shortname ".jpg")))
      (gimp-file-save 1 dupImage dup-layer (string-append fullname ".jpg") (string-append shortname ".jpg"))
   )
)

;;;;clean up by deleting the dupImage 
    (gimp-image-delete dupImage)                
   
   
   (gimp-displays-flush)
   (gimp-image-undo-group-end image)
   (gimp-context-pop)
)
)



(script-fu-register "script-fu-resize-and-save-image"                 
                    "Resize and Save Image"
                     "(Requires the Liqid Rescale Plug-in) Resizes and Saves Image to the same location as Original Image"
                    "Graechan"
                    "Graechan"
                    "2012"
                    "RGB*"
                    SF-IMAGE      "image"      0
                    SF-DRAWABLE   "drawable"   0
                    SF-ADJUSTMENT "Output width (pixels)" '(1920 1 5000 1 100 0 1)
                    SF-ADJUSTMENT "Output height(pixels)" '(1200 1 5000 1 100 0 1)
               SF-OPTION "Scaling method" '("Liquid Rescale" "Scale")
               SF-TOGGLE     "Save as PNG" FALSE
               SF-TOGGLE     "Save as JPG" FALSE
)

Attachment:
Resize and Save Image.scm [3.74 KiB]
Downloaded 93 times

_________________
Image
No matter how much you push the envelope, it'll still be stationery.


Top
 Post subject: Re: Help to use liquid resize in batch (or with a script )
PostPosted: Sun Feb 26, 2012 12:55 pm  (#34) 
Offline
GimpChat Member

Joined: Mar 14, 2011
Posts: 998
PhotoComix wrote:
I never did but i know is possible just i have no idea how

what i need is scale a series of images each to all most commune wallpaper sizes
and save them in a new folder adding to the images names the size

...
PS about saving have to indicate manually where would be not the problem, the problem i need to solve is how automatically apply Liquid Rescale as indicated

PC,

Why not use Liquid Rescale and Dave's Batch processing both of which are available in portable gimp?

Partha


Top
 Post subject: Re: Help to use liquid resize in batch (or with a script )
PostPosted: Sun Feb 26, 2012 4:40 pm  (#35) 
Offline
GimpChat Member

Joined: Apr 12, 2010
Posts: 5870
Quote:
PC,

Why not use Liquid Rescale and Dave's Batch processing both of which are available in portable gimp?


The script use Liquid Rescale , for what a wished ( use it in batch to rescale at several different wallpaper size a series of images and save everything with same name and size included in the name ) do manually would be a nightmare...well just impossible at least for my nerves

i didn't think i could use DBP for scaling without respecting the image ratio, but even if i could would remain the same problem (you have no idea of how much are the wallpaper sizes...and supreme irony in the list seems not included the size of my screen (1600x1060)

_________________
My 3D Gallery on Deviantart http://photocomix2.deviantart.com/
Main gallery http://www.flickriver.com/photos/photocomix-mandala/
Mandala and simmetry http://www.flickriver.com/photos/photocomix_mandala/

Image

Mrs Wilbress


Top
Post new topic Reply to topic  [ 35 posts ]  Go to page Previous  1, 2

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) converting 32 bit images to 8 bit using batch script

5

No new posts Attachment(s) Seeking Help with First Multi-File Batch Script

9

No new posts Attachment(s) Batch export all opened images script for GIMP [Update]

13

No new posts Attachment(s) Liquid rescale fot Gimp 2.10.18

2

No new posts Attachment(s) Can't resize brush

23



* Login  



Powered by phpBB3 © phpBB Group