Code Monkey home page Code Monkey logo

cropall's People

Contributors

happytetrahedron avatar maxgyver83 avatar pknowles avatar superstar54 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cropall's Issues

Error: no resize specified. Not resizing

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) + "\""

Crop allowing different aspect ratio

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.

On custom aspect ratio the preview distorts

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!

Crop button not there

Can be solved by replacing line 248 with

self.inputs[-1].grid(row=0, column=9, sticky="nsew")

Do not overwrite crops

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!

Fork specifically for book scanning

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:

  • Changed the bounding box from yellow to red
  • A much more granular "zooming" factor
  • Key-bindings for arrow keys, and ctrl+arrow keys
  • key binding for rotating
  • deskewing before cropping

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**.

Add some way to configure the output path and filename

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}?

Installation on Ubuntu 14.10

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:

  • Cloned with git clone https://github.com/pknowles/cropall.git
  • Changed shebang of cropall.py from #!/bin/python to #! /usr/bin/env python2
  • installed python-tk : sudo apt-get install python-tk
  • installed python-imaging-tk : sudo apt-get install python-imaging-tk
  • run script from terminal window with ./cropall.py

Maybe this info should be added to README.md ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.