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

Automate image cropping of scanned images #14

Open
pschild opened this issue Nov 9, 2018 · 5 comments
Open

Automate image cropping of scanned images #14

pschild opened this issue Nov 9, 2018 · 5 comments
Assignees

Comments

@pschild
Copy link
Owner

pschild commented Nov 9, 2018

There will be cases in which multiple old photos are scanned as one image file. Maybe it's possible to detect and extract every single image and save it as own file.
GIMP and ImageMagick offer such functionality, but it's not obvious how to make it work with Node.js.

Some ideas and links:

A) ImageMagick
http://www.fmwconcepts.com/imagemagick/multicrop/index.php
http://www.fmwconcepts.com/imagemagick/index.php => Windows users

https://stackoverflow.com/questions/48557612/programmatically-divide-scanned-images-into-separate-images

Algorithm
http://www.sethanil.com/exploring-software/49-image_cropping
https://opensourceforu.com/2015/03/automate-the-cropping-of-photos-from-scanned-album-pages/

PHP Manual
http://php.net/manual/de/book.imagick.php

B) Scan Software
https://autosplitter.com/

C) GIMP Plugin
http://francoismalan.com/2013/01/how-to-batch-separate-crop-multiple-scanned-photos/

  • Search for "calling your script via command line at the end of the scanning step"

GIMP CLI
GIMP CLI Batch Mode

@pschild pschild self-assigned this Nov 9, 2018
@pschild
Copy link
Owner Author

pschild commented Nov 10, 2018

The following command works with the script script_fu_BatchDivideScannedImages:

& "C:\Program Files\GIMP 2\bin\gimp-2.10.exe" -i -b '(script_fu_BatchDivideScannedIm
ages \"C:\\Users\\schild\\Desktop\\test\" 0 FALSE 0 10 TRUE TRUE 25 100 TRUE \"#FFFFFF\" 0 25 25 TRUE \"C:\\Users\\sc
hild\\Desktop\\test\" 0 0.8 \"Crop\" 1)'

To make it work with -i param, the following lines were commented:

;(set! tempdisplay (car (gimp-display-new tempImage)))
...
;(begin
    ;(gimp-display-delete tempdisplay)
;)

@pschild
Copy link
Owner Author

pschild commented Nov 10, 2018

CLI params:

name type default
inSourceDir string ""
inLoadType enum 0=JPG,1=JPEG,2=BMP,3=PNG,4=TIF,5=TIFF 0
inSquareCrop boolean FALSE
inPadding number 0
inLimit number 10
inDeskew boolean TRUE
inAutoClose boolean TRUE
inThreshold number 25
inSize number 100
inDefBg boolean TRUE
inBgCol string "#FFFFFF"
inCorner enum 0=Top Left,1=Top Right,2=Bottom Left,3=Bottom Right 0
inX number 25
inY number 25
inSaveInSourceDir boolean TRUE
inDestDir string ""
inSaveType enum 0=.jpg,1=.png 0
inJpgQual number 0.8
inFileName string "Crop"
inFileNumber number 1

@pschild
Copy link
Owner Author

pschild commented Nov 11, 2018

added in f67f1bc

@pschild
Copy link
Owner Author

pschild commented Nov 11, 2018

$image = new Imagick($_FILES['image_data']['tmp_name']);

@pschild
Copy link
Owner Author

pschild commented Feb 4, 2019

May be use a JS lib? http://camanjs.com/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant