BookCrop - batch crop right/left page images

General discussion about software packages and releases, new software you've found, and threads by programmers and script writers.

Moderator: peterZ

dtic
Posts: 464
Joined: 06 Mar 2010, 18:03

Re: BookCrop - batch crop right/left page images

Post by dtic »

Ok. The sw=0 is the problem here. If you open BookCrop.ahk in Notepad again and go to the line you added previously

Code: Select all

Msgbox sh=%sh%`nsw=%sw%`nscreenheight=%a_screenheight%`nscreenwidth=%a_screenwidth%
and make a new line directly below it and put this on the new line

Code: Select all

sw := A_screenwidth
and save and run it again. After that I think the preview will show in a window that horizontally covers the whole screen. I think the program will then be functional.

I'm still not sure what caused sw=0 in the first place. If the above works good enough for you then you can just remove the line starting with "Msgbox sh= ..." that we added and save and keep using the BookCrop.ahk file.
But if you'd like to help troubleshoot the cause of the problem some more then go to this Autohotkey forum post and copy and paste the code there to a blank notepad file and save as test.ahk and then run it. A box should pop up that looks something like this:
1.png
1.png (15.36 KiB) Viewed 10792 times
Check if there is a line named "Width" and one named "Height" in the list. Or do the lines have words in German? If so what would the equivalent of "Width" and "Height" be in the list?
hatatat
Posts: 12
Joined: 01 Apr 2012, 06:53
Number of books owned: 0
Country: Germany

Re: BookCrop - batch crop right/left page images

Post by hatatat »

Please find attached the values I get on my German computer.

As a consequence, I made this:

Code: Select all

Loop 283
	{
;	 if (objFolder.GetDetailsOf(objFolder.Items, A_Index) = "Width")
	 if (objFolder.GetDetailsOf(objFolder.Items, A_Index) = "Breite")
		 imgw := objFolder.GetDetailsOf(objFolderItem, A_Index)
;	 if (objFolder.GetDetailsOf(objFolder.Items, A_Index) = "Height")
	 if (objFolder.GetDetailsOf(objFolder.Items, A_Index) = "Höhe")
		 imgh := objFolder.GetDetailsOf(objFolderItem, A_Index)
	}
And now I can see the stagged jpeg.

This seems to be the solution!!!!

Your are great!!!!!!

Thanks a lot!!!!!
Attachments
extended-properties.jpg
extended-properties.jpg (60.51 KiB) Viewed 10785 times
dtic
Posts: 464
Joined: 06 Mar 2010, 18:03

Re: BookCrop - batch crop right/left page images

Post by dtic »

Nice! Good teamwork in tracking down the issue. :)

I'll add a fix for this in the next BookCrop release. However now I worry that BookCrop errors also for a lot of other non-english system languages. Can you help test one more thing? Another method to get the height and width that perhaps does not have the same problem.
Save this to test.ahk, edit the path to an imagefile and then run it.

Code: Select all

file = C:\some\folder\pageimage.jpg
msgbox % heightcheck(file)
heightcheck(x) {
Img := ComObjCreate("WIA.ImageFile")
Img.LoadFile(x)
Return "height = " Img.Height "`nwidth = " Img.Width
}
Does the messagebox then display the correct image dimensions?
hatatat
Posts: 12
Joined: 01 Apr 2012, 06:53
Number of books owned: 0
Country: Germany

Re: BookCrop - batch crop right/left page images

Post by hatatat »

Yeeeeeees, that was nice teamwork!

Your approach seems to work: the messagebox displays the image dimensions correctly.
hatatat
Posts: 12
Joined: 01 Apr 2012, 06:53
Number of books owned: 0
Country: Germany

Re: BookCrop - batch crop right/left page images

Post by hatatat »

I have another question :-)

When I run now BookCrop against a subdirectory with 71 jpg files (160 MBytes size in total), the BookCrop.ahk_over.png file is created correctly.

I select a crop region and press the "crop" button.

In my folder, a subdirectory "20160411071246" is created.

But unfortunately, there are no files in it. :(

I tried to debug with SciTE4AutoHotkey, but somehow I have to learn here how to circumvent "non responding" issues... .

Is there perhaps another Debugger that is applicable?
dtic
Posts: 464
Joined: 06 Mar 2010, 18:03

Re: BookCrop - batch crop right/left page images

Post by dtic »

hatatat wrote:Your approach seems to work: the messagebox displays the image dimensions correctly.
Good. I've uploaded version 160411 with a fix for the language bug.

Sorry to hear there is another possible bug. I don't know of any debugger that would help here. But try this. Find the line

Code: Select all

Run "%cropper%" %rot% -crop %W%x%H%+%X%+%Y% -outfile "%xdir2%\%xname%" "%val%",,hide
and add this line below it and save

Code: Select all

msgbox Run "%cropper%" %rot% -crop %W%x%H%+%X%+%Y% -outfile "%xdir2%\%xname%" "%val%",,hide
When you then try to crop a messagebox will show the attempted crop command with parameters. It should look something like

Code: Select all

Run "C:\folder\jpegtran.exe" -crop 3875x2235+330+600 -outfile "C:\dir\20160411081012\0002R.jpg" "C:\dir\0002R.jpg" ,,hide
Does it? If yes then try the same command manually (without the ",,hide" part) in a cmd window and see if jpegtran crops the file correctly.
hatatat
Posts: 12
Joined: 01 Apr 2012, 06:53
Number of books owned: 0
Country: Germany

Re: BookCrop - batch crop right/left page images

Post by hatatat »

Hi,

so this was my error.

I had a dll "jpeg62.dll" close to BookCrop.ahk, but no "libjpeg-62.dll".

After changing this, it worked well.

Perhaps an error messsage might make sense?

Again: thanks a lot for your very good support!
dtic
Posts: 464
Joined: 06 Mar 2010, 18:03

Re: BookCrop - batch crop right/left page images

Post by dtic »

Glad it worked out! I'll add a check for the correct .dll file.

edit: Done. version 160412: fix: errormessage if libjpeg-62.dll missing
bartek158
Posts: 40
Joined: 02 Dec 2016, 04:47
Number of books owned: 0
Country: Poland

Re: BookCrop - batch crop right/left page images

Post by bartek158 »

Hi
I just installed everything again ( GraphicsMagick-1.3.25-Q8 , libjpeg-turbo-gcc64 , bookcrop 160412, win 10 64bit not Eng)
I have in one folder left pages and in second folder right pages , I crop each folder separately but in output folder there aren't left pages . Croping riggh pages is sucesfull.
https://www.youtube.com/watch?v=3cOTBnhG8xA

Whot can be reason of this problem ?
dtic
Posts: 464
Joined: 06 Mar 2010, 18:03

Re: BookCrop - batch crop right/left page images

Post by dtic »

I did a test just now. First on a folder with both R and L images (0001R.jpg, 0001L.jpg, ... ). It works in both regular mode and RL mode. I also tried a folder with only R images and one with only L images. Also works. So I don't know what causes the problem for you.

Have you tried it on different L images? It might be some faulty image file that causes the problem. Test with only a few L images. You can also as a test copy some of the R images to a new folder and change the R to L in the filenames and then try BookCrop again and see if that triggers the problem. If it does then the problem is certain to be in BookCrop and not the image files.

I tested with BookCrop 160412 , GraphicsMagick-1.3.25-Q8-win64-dll.exe , libjpeg-turbo-1.5.1-gcc.exe ( libjpeg-62.dll , jpegtran.exe ) , Win10 64bit

I did have an issue where GraphicsMagick wasn't found. GM stores its location in a different registry location in the latest 64bit version it appears. But that is a different issue than the one you are experiencing.
But if anyone else runs into this GM issue then a temporary workaround is to use an older GM version or alternatively to edit the BookCrop.ahk and add a new line below line 165 with this text

Code: Select all

binpath = C:\Program Files\GraphicsMagick-1.3.25-Q8\
but change the path to point to the GM folder on your PC
Post Reply