Welcome Guest.   Make a donation to an author on the site April 17, 2014, 01:33:26 PM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
The N.A.N.Y. Challenge 2012! Download dozens of custom programs!
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: GIMP script to batch split + rotate TIFF images  (Read 10823 times)
Nod5
Supporting Member
**
Posts: 716



View Profile Give some DonationCredits to this forum member
« on: March 12, 2009, 05:15:20 PM »

I request a GIMP script that will batch split and then rotate TIFF images.

I will make a bunch of scans as TIFF images (two booklet sized pages on each image) that I want transformed like this:
1. split in half, 2. rotated , 3. make one pdf of all the rotated, single page image files

I'm only looking for help with step 1 & 2 here.

I've briefly looked into learning GIMP scripting myself (might come in handy) but chances are someone here already knows scripting for GIMP and can kickstart me on this.   tellme

edit: I should add that I my input for this will be one TIFF containing multiple images (not multiple separate TIFF files with one image in each)
« Last Edit: March 12, 2009, 05:26:41 PM by Nod5 » Logged
Ehtyar
Supporting Member
**
Posts: 1,236



That News Guy

see users location on a map View Profile Read user's biography. Give some DonationCredits to this forum member
« Reply #1 on: March 12, 2009, 11:46:40 PM »

GIMP is not the place for batch image processing. I would recommend you try something like ImageMagick.

Ehtyar.
Logged
Nod5
Supporting Member
**
Posts: 716



View Profile Give some DonationCredits to this forum member
« Reply #2 on: March 13, 2009, 02:13:05 AM »

Ok, but I got the impression that GIMP scripting would be pretty versatile. I've glanced at ImageMagick (and GraphicsMagick ) before but never gotten around to learn the details (or at least not learned them enough to remember them). So ok, I extend the request to them too so if anyone with experience with them can whip up a script (or rather a long command line string) to do what I'm after in step 1 & 2 then that'd be great. You see this week I have not enough spare time or spare free brain space to myself read manuals for these tools so that's why I'm making a request instead.
Logged
ewemoa
Honorary Member
**
Posts: 2,233



View Profile Give some DonationCredits to this forum member
« Reply #3 on: March 13, 2009, 03:52:33 AM »

Perhaps the following will get the ball rolling:


Translated -- how about something like the following?

  • use mogrify to rotate
  • use mogrify with crop or extract to get at one page
  • use mogrify with crop or extract to get at the other page

Perhaps there are other options to mogrify that would be better choices smiley

Don't know what platform is relevant here, but if it's Windows, may be the following will be of some use:

http://www.imagemagick.or...topic.php?f=8&t=12926
Logged
Nod5
Supporting Member
**
Posts: 716



View Profile Give some DonationCredits to this forum member
« Reply #4 on: March 13, 2009, 05:34:04 PM »

Great, that got me going a bit! Rotation: done.
[copy or print]
mogrify.exe -rotate -90 "___filepath___"
Split in halfs: problems. This gives me one of the two pages on each image. But crops away the other.
[copy or print]
mogrify.exe -rotate -90 -crop 100%x50% "___filepath___"
But I can't yet grasp how to target the right half of the image via the geometry option
http://imagemagick.org/sc...e-processing.php#geometry

When I've sorted the blanks I think this strategy would work (done in steps via AHK):
1. make two copies of the TIFF
2. on copy1 do -rotate -90 -crop 100%x50%
3. on copy2 do __________ [crop that leaves the right hand half of the image]
4. _______ thus combining them like this: copy1subimage1, copy2subimage1, copy1subimage2, ... (or extract them and name the output in that order)
5. make pdf

edit:
on second thought, rotate upside down, chop , rotate back should do it.
Tried to put it together in AHK but it is not running. Some error in the AHK code I think. Time to sleep, I'll try again tomorrow. Anyone else spotting errors?
[copy or print]
FileCopy, %1%, 1.tiff
FileCopy, %1%, 2.tiff

mogpath = C:\test\ImageMagick-6.5.0-0\mogrify.exe

RunWait, %comspec% /c ""%mogpath%" -rotate -90 -chop 50x0`%

"%A_Scriptdir%\1.tif""
RunWait, %comspec% /c ""%mogpath%" -rotate 90 "%A_Scriptdir%\2.tif""
RunWait, %comspec% /c ""%mogpath%" -chop 50x0`%

"%A_Scriptdir%\2.tif""
RunWait, %comspec% /c ""%mogpath%" -rotate 180 "%A_Scriptdir%\2.tif""
« Last Edit: March 13, 2009, 06:01:10 PM by Nod5 » Logged
Ehtyar
Supporting Member
**
Posts: 1,236



That News Guy

see users location on a map View Profile Read user's biography. Give some DonationCredits to this forum member
« Reply #5 on: March 13, 2009, 05:56:21 PM »

Perhaps if you supplied a sample image we'd be more able to help you with actual command lines.

Ehtyar.
Logged
Nod5
Supporting Member
**
Posts: 716



View Profile Give some DonationCredits to this forum member
« Reply #6 on: March 13, 2009, 06:17:17 PM »

I'm attaching a mockup file that roughly illustrates the format of the input (I used imagemagick to join two tiffs together... so I'm slowly learning something  cheesy)

* adjoin.zip (939.24 KB - downloaded 188 times.)
« Last Edit: March 13, 2009, 06:21:16 PM by Nod5 » Logged
ewemoa
Honorary Member
**
Posts: 2,233



View Profile Give some DonationCredits to this forum member
« Reply #7 on: March 13, 2009, 10:48:27 PM »

Don't know if the following is of any help, but after looking at:

  http://www.imagemagick.or.../Usage/crop/#crop_percent

I tried the following (with success locally) to get at the right-half of an image:

Quote
convert inputimage.extension -gravity east -crop 50%x100% outputimage.extension

FWIW, I noticed a "Offsets in geometry" section in:

  http://imagemagick.org/sc...e-processing.php#geometry

and a bit on -gravity at:

  http://imagemagick.org/sc...-line-options.php#gravity

The following page had some pointers to groups of examples:

  http://www.imagemagick.org/Usage/
Logged
Nod5
Supporting Member
**
Posts: 716



View Profile Give some DonationCredits to this forum member
« Reply #8 on: March 14, 2009, 05:58:16 AM »

TIFFRotateSplitMakePDF v090314, http://nod5.dcmembers.com...ffrotatesplitmakepdf.html
by Nod5, with help from ewemoa

input: multiimage file.tif with two scanned pages per image (= a bookspread, tilted 90 degrees)
what the script does: rotate 90 degrees, split each image in two (L/R page), output file.pdf with all split images in page order

tiffrotatesplitmakepdf.zip contains .exe , .ahk (source) and md5 hashes. made in Autohotkey. requires: http://www.imagemagick.org/


Thank you ewemoa!  Thmbsup
Logged
ewemoa
Honorary Member
**
Posts: 2,233



View Profile Give some DonationCredits to this forum member
« Reply #9 on: March 14, 2009, 06:32:18 AM »

Congratulations!  Glad that it's working for you smiley

(Thanks to Ehtyar for bringing up ImageMagick -- it's been years since I've used it -- didn't know there was a Windows port!)
Logged
Nod5
Supporting Member
**
Posts: 716



View Profile Give some DonationCredits to this forum member
« Reply #10 on: March 14, 2009, 06:39:52 AM »

Yes, thanks to Ehtyar too!

TIFFRotateSplitMakePDF v090315, http://nod5.dcmembers.com...ffrotatesplitmakepdf.html
v090315: ctrl+drop to skip rotate
« Last Edit: March 14, 2009, 08:35:19 AM by Nod5 » Logged
mouser
First Author
Administrator
*****
Posts: 32,655



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #11 on: March 14, 2009, 06:53:47 AM »

nice  thumbs up
Logged
Ehtyar
Supporting Member
**
Posts: 1,236



That News Guy

see users location on a map View Profile Read user's biography. Give some DonationCredits to this forum member
« Reply #12 on: March 14, 2009, 03:58:08 PM »

No probs guys. I ran across it when I started using PHP, ImageMagick does a much better job than GD. The way GraphicsMagick talks itself up is interesting, I can't imagine all their claims can be justified as easily as they're spoken.

Nice job Nod5.

Ehtyar.
Logged
davisjt1977
Participant
*
Posts: 2

View Profile Give some DonationCredits to this forum member
« Reply #13 on: March 18, 2009, 01:28:16 AM »

Just starting.
This script is exactly what I need.
Have downloaded & installed AHK & ImageMagick.
But get error that I have not been able to resolve.
ImageMagick directory not found. Set it in TIFFRotateSplitMakePDF.ini
But I have edited this file w/ complete path.
Pls help
thanks


* untitled.bmp (187.94 KB, 641x100 - viewed 316 times.)
Logged
Nod5
Supporting Member
**
Posts: 716



View Profile Give some DonationCredits to this forum member
« Reply #14 on: March 19, 2009, 05:19:24 PM »

Welcome to DC davisjt1977!
The default ini is a bit confusing - you have to remove the comment character ( ; ) in it. Check if you've done that. So this won't work:
[copy or print]
;imagemagickdirectory=C:\program files\ImageMagick-6.5.0-0
this works:
[copy or print]
imagemagickdirectory=C:\program files\ImageMagick-6.5.0-0

edit: I've now updated the program so that the comment character from now on never gets added to the ini:
http://nod5.dcmembers.com...ffrotatesplitmakepdf.html
v090319 ini bugfix
« Last Edit: March 19, 2009, 05:26:51 PM by Nod5 » Logged
davisjt1977
Participant
*
Posts: 2

View Profile Give some DonationCredits to this forum member
« Reply #15 on: April 23, 2009, 09:44:44 AM »

Thanks
Got it working
This is a fantastic tool & I have customized it to my situation.
 Kiss
Logged
Nod5
Supporting Member
**
Posts: 716



View Profile Give some DonationCredits to this forum member
« Reply #16 on: April 24, 2009, 03:21:47 AM »

Cool! If you think any customization you add might be useful to others too then just post the code and I'll see if I can add it to the program. Thmbsup
Logged
ewemoa
Honorary Member
**
Posts: 2,233



View Profile Give some DonationCredits to this forum member
« Reply #17 on: September 01, 2011, 10:10:48 PM »

FWIW, I recently had occasion to reuse the splitting functionality described earlier in this topic:

Quote
convert inputimage.extension -gravity east -crop 50%x100% outputimage.extension

To get at the other half, I used:

[copy or print]
convert inputimage.extension -gravity west -crop 50%x100% outputimage.extension

Using the +repage option seemed to give better results as well:

[copy or print]
convert inputimage.extension -gravity east -crop 50%x100% +repage outputimage.extension
convert inputimage.extension -gravity west -crop 50%x100% +repage outputimage.extension

FWIW, it may be that +repage is only of relevance to one of the two invocations.

This was in the context of transforming an existing PDF somewhat similar in format to the TIFF described.  The original PDF in this case had side-by-side pages (instead of one above another) on each page (so no rotation required).  Perhaps the original program can be modified to operate on such PDFs smiley
« Last Edit: September 01, 2011, 10:14:42 PM by ewemoa » Logged
Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.042s | Server load: 0.08 ]