Skip to content

Commit

Permalink
Merge pull request #41 from c-magyar/master
Browse files Browse the repository at this point in the history
Copy file if no cropping or rotation is required.
  • Loading branch information
jepler authored May 7, 2017
2 parents bd1fbfe + aff540a commit e8a88e5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
5 changes: 4 additions & 1 deletion cropgtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,11 @@ def run(self):
self.log("Skipped %s" % os.path.basename(image_name))
continue # user hit "cancel" on save dialog

# Copy file if no cropping or rotation.
if (r+b-l-t) == (drag.w+drag.h) and rotation =="none":
command = ['nice', 'cp' , image_name, target]
# JPEG crop uses jpegtran
if image_type is "jpeg":
elif image_type is "jpeg":
command = ['nice', 'jpegtran']
if not rotation == "none": command.extend(['-rotate', rotation])
command.extend(['-copy', 'all', '-crop', cropspec,'-outfile', target, image_name])
Expand Down
16 changes: 11 additions & 5 deletions cropgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,18 @@ def set_busy(new_busy=True):
if v == -1: break # user closed app
if v == 0: continue # user hit "next" / escape

# Copy file if no cropping.
if (r+b-l-t) == (drag.w+drag.h):
command = ['nice', 'cp' , image_name, target]
# call jpegtran
base, ext = os.path.splitext(image_name)
t, l, r, b = drag.get_corners()
cropspec = "%dx%d+%d+%d" % (r-l, b-t, l, t)
target = base + "-crop" + ext
task.add(['nice', 'jpegtran', '-copy', 'all', '-crop', cropspec, '-outfile', target, image_name], target)
else:
base, ext = os.path.splitext(image_name)
t, l, r, b = drag.get_corners()
cropspec = "%dx%d+%d+%d" % (r-l, b-t, l, t)
target = base + "-crop" + ext
command=['nice', 'jpegtran', '-copy', 'all', '-crop', cropspec, '-outfile', target, image_name]
print " ".join(command)
task.add(command, target)
finally:
task.done()

Expand Down

0 comments on commit e8a88e5

Please sign in to comment.