Skip to content

Commit

Permalink
Removing -progressive argument on jpegtran
Browse files Browse the repository at this point in the history
Keep images in baseline mode with `-progressive` argument removal on all jpegtran commands.

See cquest#45
  • Loading branch information
Stefal committed Apr 9, 2024
1 parent 16d6ae8 commit 44965c0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/blur/blur.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ def blurPicture(picture, keep):

# jpegtran "drop"
print( 'crop size', os.path.getsize(tmpcrop))
p = subprocess.run('jpegtran -progressive -optimize -copy all -trim -drop +%s+%s %s %s > %s' % (crop_rects[c][0], crop_rects[c][1], tmpcrop, tmp, tmp+'_tmp'), shell=True)
p = subprocess.run('jpegtran -optimize -copy all -trim -drop +%s+%s %s %s > %s' % (crop_rects[c][0], crop_rects[c][1], tmpcrop, tmp, tmp+'_tmp'), shell=True)
print( 'after drop', os.path.getsize(tmp+'_tmp'))
if p.returncode != 0 :
print('crop %sx%s -> recrop %sx%s' % (img.width, img.height, crop_rects[c][2], crop_rects[c][3]))
subprocess.run('jpegtran -crop %sx%s+0+0 %s > %s' % (img.width, img.height, tmpcrop, tmpcrop+'_tmp'), shell=True)
p = subprocess.run('jpegtran -progressive -optimize -copy all -trim -drop +%s+%s %s %s > %s' % (crop_rects[c][0], crop_rects[c][1], tmpcrop+'_tmp', tmp, tmp+'_tmp'), shell=True)
p = subprocess.run('jpegtran -optimize -copy all -trim -drop +%s+%s %s %s > %s' % (crop_rects[c][0], crop_rects[c][1], tmpcrop+'_tmp', tmp, tmp+'_tmp'), shell=True)
if img.height != crop_rects[c][3]:
input()

Expand All @@ -128,8 +128,8 @@ def blurPicture(picture, keep):
subprocess.run('exiftool -overwrite_original -tagsfromfile %s %s' % (tmp, tmp+'_tmp'), shell=True)
print('after recompressing original', os.path.getsize(tmp+'_tmp'))
os.replace(tmp+'_tmp', tmp)
print('jpegtran -progressive -optimize -copy all -trim -drop +%s+%s %s %s > %s' % (crop_rects[c][0], crop_rects[c][1], tmpcrop, tmp, tmp+'_tmp'))
subprocess.run('jpegtran -progressive -optimize -copy all -trim -drop +%s+%s %s %s > %s' % (crop_rects[c][0], crop_rects[c][1], tmpcrop, tmp, tmp+'_tmp'), shell=True)
print('jpegtran -optimize -copy all -trim -drop +%s+%s %s %s > %s' % (crop_rects[c][0], crop_rects[c][1], tmpcrop, tmp, tmp+'_tmp'))
subprocess.run('jpegtran -optimize -copy all -trim -drop +%s+%s %s %s > %s' % (crop_rects[c][0], crop_rects[c][1], tmpcrop, tmp, tmp+'_tmp'), shell=True)
os.replace(tmp+'_tmp', tmp)

# save detected objects data in JPEG comment at end of file
Expand Down

0 comments on commit 44965c0

Please sign in to comment.