mirror of
https://github.com/Kilian/Trimage.git
synced 2026-01-26 01:58:41 -05:00
show old filesize next to new filesize, implement jpg optimisation
This commit is contained in:
parent
b02d6e0aa6
commit
3ec1938b3e
5 changed files with 15 additions and 13 deletions
Binary file not shown.
|
Before Width: | Height: | Size: 603 B After Width: | Height: | Size: 554 B |
BIN
list-add.png
BIN
list-add.png
Binary file not shown.
|
Before Width: | Height: | Size: 601 B After Width: | Height: | Size: 678 B |
7
todo
7
todo
|
|
@ -12,18 +12,17 @@
|
|||
- jpegoptim *
|
||||
- libjpeg/jpegtran *
|
||||
gif:
|
||||
- optipng *
|
||||
- optipng * no
|
||||
- gifsicle * (maybe)
|
||||
* = available in ubuntu
|
||||
|
||||
trimage: simple gui for:
|
||||
optipng for png and gif, jpegoptim for jpeg. both are available in ubuntu as dependencies (our primary platform)
|
||||
|
||||
^ no gif. optipng optimized gif by converting to png
|
||||
|
||||
==========================================
|
||||
todo app wise
|
||||
- implement jpegoptim
|
||||
- implement something for gifs
|
||||
- implement something for gifs (or not)
|
||||
- implement drag and drop on table
|
||||
- clean up code, make it PEP-8
|
||||
- figure out what to do with:
|
||||
|
|
|
|||
21
trimage.py
21
trimage.py
|
|
@ -23,9 +23,11 @@ class StartQT4(QMainWindow):
|
|||
QObject.connect(self.quit_shortcut, SIGNAL("activated()"), qApp, SLOT('quit()'))
|
||||
QObject.connect(self.ui.processedfiles, SIGNAL("dragEnterEvent()"), self.file_drop)
|
||||
|
||||
|
||||
def file_drop(self):
|
||||
print "booya"
|
||||
|
||||
|
||||
def file_dialog(self):
|
||||
fd = QFileDialog(self)
|
||||
images = fd.getOpenFileNames(self,
|
||||
|
|
@ -41,9 +43,9 @@ class StartQT4(QMainWindow):
|
|||
|
||||
|
||||
def recompress_files(self):
|
||||
newimage = self.imagelist
|
||||
imagelistcopy = self.imagelist
|
||||
self.imagelist = []
|
||||
for image in newimage:
|
||||
for image in imagelistcopy:
|
||||
self.compress_file(image[-1])
|
||||
|
||||
|
||||
|
|
@ -52,20 +54,21 @@ class StartQT4(QMainWindow):
|
|||
oldfile = QFileInfo(filename);
|
||||
name = oldfile.fileName()
|
||||
oldfilesize = oldfile.size()
|
||||
oldfilesizestr = size(oldfilesize, system=alternative)
|
||||
|
||||
if name.endsWith("jpg"):
|
||||
print "run jpegoptim"
|
||||
runfile = system('ls')
|
||||
runstr = 'jpegoptim --strip-all -f "' + str(filename) + '"'
|
||||
runfile = system(runstr)
|
||||
|
||||
elif name.endsWith("png"):
|
||||
runstr = 'optipng -force "' + str(filename) + '"'
|
||||
#runstr = 'optipng -force -o7 "' + str(filename) + '"; advpng -z4 "' + str(filename) + '"' ## don't do advpng yet
|
||||
runstr = 'optipng -force -o7 "' + str(filename) + '"'
|
||||
runfile = system(runstr)
|
||||
|
||||
else:
|
||||
print "run something for gif"
|
||||
runfile = system('ls')
|
||||
|
||||
|
||||
if runfile == 0:
|
||||
newfile = QFile(filename)
|
||||
newfilesize = newfile.size()
|
||||
|
|
@ -74,7 +77,7 @@ class StartQT4(QMainWindow):
|
|||
ratio = 100 - (float(newfilesize) / float(oldfilesize) * 100)
|
||||
ratiostr = "%.1f%%" % ratio
|
||||
|
||||
self.imagelist.append((name, newfilesizestr, ratiostr, filename))
|
||||
self.imagelist.append((name, oldfilesizestr, newfilesizestr, ratiostr, filename))
|
||||
self.update_table()
|
||||
|
||||
else:
|
||||
|
|
@ -87,7 +90,7 @@ class StartQT4(QMainWindow):
|
|||
# set table model
|
||||
tmodel = tri_table_model(self,
|
||||
self.imagelist,
|
||||
[' Filename ', ' Size ', ' Compressed '])
|
||||
['Filename', 'Old Size', 'New Size', 'Compressed'])
|
||||
tview.setModel(tmodel)
|
||||
|
||||
# set minimum size of table
|
||||
|
|
@ -102,7 +105,7 @@ class StartQT4(QMainWindow):
|
|||
nrows = len(self.imagelist)
|
||||
for row in range(nrows):
|
||||
tview.setRowHeight(row, 25)
|
||||
tview.setColumnWidth(0,400)
|
||||
tview.setColumnWidth(0,300)
|
||||
tview.setDragDropMode(QAbstractItemView.DropOnly)
|
||||
tview.setAcceptDrops(True)
|
||||
self.enable_recompress()
|
||||
|
|
|
|||
BIN
view-refresh.png
BIN
view-refresh.png
Binary file not shown.
|
Before Width: | Height: | Size: 2 KiB After Width: | Height: | Size: 2 KiB |
Loading…
Add table
Add a link
Reference in a new issue