pknowles / cropall Goto Github PK
View Code? Open in Web Editor NEWInteractive semi-batch image cropper. One click to crop load next.
License: GNU General Public License v3.0
Interactive semi-batch image cropper. One click to crop load next.
License: GNU General Public License v3.0
The error can be avoided by replacing line 392
c += " -resize \"" + str(resize_width) + "x" + str(resize_height) + ">\""
against
if (resize_width > 0):
c += " -resize \"" + str(resize_width) + "x" + str(resize_height) + ">\""
c += " \"" + os.path.join(self.outDir, self.currentName) + "\""
Perhaps aspect ratio is the wrong word, if I drag a square over a range of 100x123 pixels that the image I want to save. After making that square I'd like to drag the handles of it to make more minor adjustments, also using the arrow keys for minor pixel adjustments would be great.
Hi. I've changed the line 422 like that:
preview = ImageOps.expand(preview, border=((bbox[2]-preview.size[0])//2, (bbox[3]-preview.size[1])//2))
to avoid that distortion.
Very helpful script.
Thank you very much!
Can be solved by replacing line 248 with
self.inputs[-1].grid(row=0, column=9, sticky="nsew")
Hi!
This program was almost excellent for me! Only thing I was missing was the option to not to rewrite cropped images (i cut scanned pages to portions of text and images).
Python is not very well known for me so I believe it can be done much better, but it's all I can do:
In "try" I added:
import time
In class MyApp(tk) I've modified getImages to make it load images sorted by name:
for i in sorted(os.listdir(dir)):
Modified binds:
#self.bind('<space>', self.save_next)
#self.bind('d', self.next)
self.bind('<space>', self.next)
self.bind('s', self.save)
And added complete "save" function:
def save(self, event=None):
box = self.getRealBox()
filename_l, file_extension_l = os.path.splitext(self.currentName)
currentName_l = filename_l + "-" + str(int(time.time())) + file_extension_l
c = "convert \"" + os.path.join(self.inDir, self.currentName) + "\""
c += " -crop " + str(box[2]-box[0]) + "x" + str(box[3]-box[1]) + "+" + str(box[0]) + "+" + str(box[1])
if (resize_width > 0):
c += " -resize \"" + str(resize_width) + "x" + str(resize_height) + ">\""
c += " \"" + os.path.join(self.outDir, currentName_l) + "\""
print c
subprocess.Popen(c, shell=True)
print "Running"
It adds to new file name datestamp, so nothing will be overwritten.
It might be useful for someone.
Best regards!
I just wanted to let you know that I made a fork of your code, and modified it to accommodate cropping scans of books. I feel like it does not have a place in your repo because you wrote this specifically for a different kind of workflow but feel free to pull in my changes.
The following changes have been done:
Thank you for sharing your work. I found your repo from your answer in this question: http://askubuntu.com/questions/97695/is-there-a-lightweight-tool-to-crop-images-quickly
PS. That person that commented on your answer was a bit of an a**.
It'd be nice to have some way to configure the the output filename (currently it's hidden in the .ini config and it's only an output path). Maybe something like a textbox that can take a format string, e.g. crops/{original}_cropped_{datetime}.{ext}
?
Hi, I am about to test the cropall.py
script on Ubuntu 14.10.
For your information, here is what I had to do to get it running:
git clone https://github.com/pknowles/cropall.git
cropall.py
from #!/bin/python
to #! /usr/bin/env python2
sudo apt-get install python-tk
sudo apt-get install python-imaging-tk
./cropall.py
Maybe this info should be added to README.md
?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.