Trimage
Trimage copied to clipboard
not a supported image file and/or not writeable [but then works anyway?]
root@localhost:/var/uploads/c# xvfb-run trimage -f 1434169021882_SU1HXzIwMTUwMTE2XzE0MTgxNS5qcGc.jpg pngcrush 1.7.65, uses libpng 1.2.49 and zlib 1.2.8 Check http://pmt.sf.net/ for the most recent version. [error] /var/uploads/c/1434169021882_SU1HXzIwMTUwMTE2XzE0MTgxNS5qcGc.jpg not a supported image file and/or not writeable File: /var/uploads/c/1434169021882_SU1HXzIwMTUwMTE2XzE0MTgxNS5qcGc.jpg, Old Size: 881 KB, New Size: 679 KB, Ratio: 22.9%
(command run as root to confirm this isn't a permissions error)
Any way to figure out why it gives me an error but then works anyway? i would like to prevent the false negatives so that i can know when it really does fail. Is this related to the fact that i don't have an X server and i'm running trimage via xvfb ?
This is all wrong, ignore this comment. ~~I'm pretty sure the issue is this line:~~ ~~https://github.com/Kilian/Trimage/blob/master/src/trimage/trimage.py#L209~~
~~I think there is a q missing. it should be:~~ ~~image = QImage(fullpath)~~ ~~Unless this is using some other Image function, but i don't see that imported anywhere, so my best guess is it is supposed to be using QImage from the import:~~ ~~from PyQt4.QtGui import *~~
~~QImage is the only imported module i can find that has a method "valid"~~
Ok, thats pretty weird. i just noticed that the version of trimage i am using on ubuntu is different than this git. I installed it with:
apt-get install trimage
The version number in the file is the same: 1.0.5. But this section of code is totally different because it is missing an indent:
if image.valid:
delegatorlist.append(image)
self.imagelist.append(ImageRow(image, self.compressing_icon))
if QSystemTrayIcon.isSystemTrayAvailable() and not self.cli:
self.systemtray.trayIcon.setToolTip("Trimage image compressor (" + str(len(self.imagelist)) + " files)")
self.setWindowTitle("Trimage image compressor (" + str(len(self.imagelist)) + " files)")
else:
print >> sys.stderr, u"[error] %s not a supported image file and/or not writeable" % image.fullpath
In this git, that second if is indented within the if image.valid check.
Ok, well indenting that section fixed it for me. I was wrong about the QImage thing.
Leaving this here for others who might have the same issue with trimage on ubuntu. When i installed it with the package manager it actually ads two trimage.py files (i don't really know why). The issue is only in one of the files.
/usr/lib/pymodules/python2.7/trimage/trimage.py <-- has bad indent. /usr/share/pyshared/trimage/trimage.py <-- perfectly fine, same as git file.
I don't know why there are two files, and i don't know why one of them is incorrect and that is the one being used by the system. this is all beyond me. But fixing that indent fixed my problem.
-Adrian
I'm seeing this issue for a couple of images as well - it appears as though trimage proceeds to optimize despite the error. They also appear to be all PNG images. Any ideas?