Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not a supported image file and/or not writeable [but then works anyway?] #36

Open
deweydb opened this issue Jun 13, 2015 · 4 comments
Open

Comments

@deweydb
Copy link

deweydb commented Jun 13, 2015

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 ?

@deweydb
Copy link
Author

deweydb commented Jun 18, 2015

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"

@deweydb
Copy link
Author

deweydb commented Jun 18, 2015

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.

@deweydb
Copy link
Author

deweydb commented Jun 18, 2015

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

deweydb referenced this issue Jun 18, 2015
this patch by Daniel Clemente and fixes an indentation error
for non-systemtray environments.
@rtindru
Copy link

rtindru commented Oct 4, 2017

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants