PMXBOT Log file Viewer

Help | Karma | Search:

#pil logs for Tuesday the 29th of October, 2013

(Back to #pil overview) (Back to channel listing) (Animate logs)
[17:39:11] <ttback> having some problem i can't resolve with Tiff file saving https://github.com/python-imaging/Pillow/issues/396
[17:39:23] <ttback> would be thankful for any tips
[17:42:38] <wiredfool> encoder error #2 I think is a general something broke error.
[17:43:17] <wiredfool> ah. sample.tiff: Bits/sample must be 1 for Group 3/4 encoding/decoding.
[17:43:33] <wiredfool> you can't save a g4 tiff in grayscale mode
[17:43:58] <wiredfool> either convert back to '1', or you need to set a different compression
[17:56:13] <wiredfool> ttback: ping
[17:56:23] <ttback> wiredfool: sorry
[17:56:27] <ttback> was testing it again
[17:56:33] <wiredfool> just making sure you saw it
[17:56:53] <ttback> i see
[17:57:03] <ttback> i am working on this legacy code
[17:57:10] <ttback> no comments on why it is doing the convert('L')
[17:57:19] <ttback> so mind explaining what g4 tiff is?
[17:57:40] <wiredfool> group 4 is a lossless b/w compression mode
[17:57:59] <wiredfool> mainly used for faxes and other scanned documents
[17:58:22] <ttback> so the current code, just save it to png in RGBA mode
[17:58:33] <wiredfool> gaussian blur doesn't make much sense/won't work for b/w files,
[17:58:33] <ttback> pageImage = pageImage.convert('RGBA')
[17:58:34] <ttback> pageImage.save(tmpFile, "PNG")
[17:58:41] <ttback> i see
[17:59:18] <wiredfool> so, likely, what you would need to do is either set the compression to None, or tiff_deflate, or something, or save as png
[17:59:18] <ttback> but this is only the saving part
[17:59:22] <ttback> it saves to PNG after blur
[17:59:29] <ttback> then do a convert png to tiff later
[17:59:55] <ttback> you mean on the save() options
[18:00:37] <ttback> i am hoping it can just blur the TIFF
[18:00:55] <ttback> without going through this TIFF->blur->save as png -> convert png tiff loop that i don't quite get
[18:01:02] <wiredfool> yeah, though, I think with 2.2.1 as released, you'd have to set img.tag[TiffImagePlugin.COMPRESSION] = None/whatever
[18:01:31] <ttback> so would that make the blur work on TIFF?
[18:01:33] <wiredfool> so, input is a b/w file
[18:01:39] <ttback> yeah
[18:01:48] <ttback> input is group 4 tiff scans i think
[18:02:01] <wiredfool> output is...
[18:02:01] <ttback> and my goal is just blur them for the photos on them
[18:02:15] <ttback> end output is one TIFF + png thumbs
[18:02:28] <ttback> but thumb is another operation
[18:02:33] <wiredfool> right
[18:02:40] <ttback> right now i am just trying to go from TIFF to TIFF with minimal operations
[18:03:18] <wiredfool> do you want tiff compression?
[18:03:21] <ttback> the original legacy hackery does TIFF->PNG->PIL BLUR->SAVE AS TMP PNG->convert png tiff
[18:03:31] <ttback> i guess you could blur the png
[18:03:45] <ttback> but based on what you said, isn't the same story with TIFF
[18:03:57] <wiredfool> well, it's just bits
[18:04:13] <wiredfool> try:
[18:04:17] <wiredfool> img.convert('L'
[18:04:18] <wiredfool> )
[18:04:37] <wiredfool> img.info['compression'] = 'tiff_deflate'
[18:04:38] <ttback> would we lose any quality if we allow tiff compression? if it is not visible, it doesn't matter
[18:04:57] <wiredfool> img.filter(ImageFilter.GaussianBlur(4))
[18:05:08] <wiredfool> I think deflate == gzip, so it's lossless
[18:05:20] <wiredfool> then img.save('out.tif')
[18:05:25] <ttback> give me a sec, was just setting up a sample for testing this
[18:08:17] <ttback> running it
[18:09:48] <ttback> it didn't throw an error
[18:09:50] <ttback> let me see the results
[18:10:45] <ttback> but unable to be opened
[18:10:57] <wiredfool> hmm.
[18:11:22] <wiredfool> compression might be funky. try img.info['compression'] = 'raw'
[18:11:46] <wiredfool> that should set you up an uncompressed tiff, at the cost of being really huge (for now)
[18:18:02] <ttback> it is
[18:18:11] <ttback> 40 mb
[18:18:24] <wiredfool> are the bits what you want though?
[18:18:27] <ttback> don't think blur happened
[18:18:30] <wiredfool> does it look ok?
[18:18:36] <wiredfool> hmmm.
[18:18:53] <ttback> it looks like exact original
[18:19:04] <ttback> wondering if i have to make it png then convert back
[18:19:08] <ttback> like it is necessary
[18:19:12] <ttback> for gaussian blur to work
[18:19:14] <wiredfool> no
[18:19:21] <wiredfool> shouldn't be anyway.
[18:19:37] <ttback> having same issue using the magickwand
[18:19:45] <ttback> don't think blur is showing up
[18:24:06] <wiredfool> can you post your test code?
[18:25:48] <ttback> okay
[18:26:53] <ttback> created a gist
[18:26:53] <ttback> https://gist.github.com/ttback/7220015
[18:27:30] <ttback> let me know if you see something wrong
[18:27:44] <ttback> someone mentioned i might have to do it with 24-bit
[18:27:47] <ttback> not sure what that means
[18:27:51] <wiredfool> filter returns a new image
[18:27:56] <ttback> yes
[18:27:57] <ttback> it does
[18:28:04] <ttback> 40mb new image saved
[18:28:04] <wiredfool> so it should be pageImage = pageImage.fillter()
[18:28:14] <ttback> sec
[18:29:07] <ttback> running again
[18:29:19] <ttback> my bad, changed my old code into broken ones
[18:30:20] <wiredfool> did that work?
[18:35:19] <ttback> just downloaded it
[18:35:21] <ttback> beauitful
[18:35:24] <ttback> it works i think
[18:35:28] <ttback> except it may be a lil too blurry
[18:35:30] <ttback> i will adjust that
[18:35:46] <wiredfool> ok
[18:36:06] <wiredfool> for compression, try 'tiff_adobe_deflate'
[18:36:45] <ttback> now i am gonna try the deflate again
[18:36:50] <wiredfool> it sounds more proprietary than tiff_deflate, but imagemagick reads and writes it
[18:36:54] <ttback> so any big diff between tiff_adobe and tiff_?
[18:37:34] <ttback> sorry that i have a little delay here, someone just told me a massive pull request didn't work as advertised, i had to merge it myself to prove my innocence
[18:37:51] <wiredfool> tiff is a mess of different things. tiff_adobe_deflate came up when I tried compressing something with LZW in either imagemagick or tiffc
[18:38:07] <wiredfool> ah. I'm going to have to run in a few myself
[18:39:55] <ttback> thanks for the help tho
[18:40:04] <ttback> this saves me like at least two days
[18:40:16] <wiredfool> cool
[18:40:18] <ttback> i was on the verge of just switching to wand
[18:40:20] <ttback> which
[18:40:24] <ttback> doesn't solve the actual problem
[18:40:41] <ttback> it looks like i'd have to tackle the compression mode again when i switch
[18:41:09] <wiredfool> in wand? or pillow
[18:41:24] <ttback> i am considering to switch to use wand
[18:41:44] <ttback> but there are some concerns
[18:41:48] <ttback> one is these old codes
[18:41:54] <ttback> i'd have to retune them every line
[18:42:08] <ttback> two is that even tho i see the blur part worked faster, when it comes to img.save
[18:42:16] <ttback> it ended up using as much time as Pillow
[18:42:21] <ttback> so overall i saved nothing
[18:42:51] <ttback> the goal to clean the mess is to get them running faster
[18:42:52] <ttback> so
[18:43:49] <ttback> deflate adobe
[18:43:52] <ttback> gives the same error
[18:43:56] <ttback> won't open on the preview tool
[18:44:04] <wiredfool> what preview tool
[18:44:10] <ttback> on the mac
[18:44:12] <wiredfool> ah
[18:44:15] <ttback> basically i use it to test if i can open it
[18:44:18] <wiredfool> do you have imagemagick?
[18:44:23] <ttback> and preview it
[18:44:24] <ttback> yeah
[18:44:26] <ttback> i do
[18:44:32] <wiredfool> what does identify -verbose say?
[18:45:07] <ttback> sample.tiff TIFF 5606x7200 5606x7200+0+0 8-bit Grayscale DirectClass 18.26MB 0.000u 0:00.000
[18:47:09] <wiredfool> ok, afk, I'll be back in a couple hours
[18:47:54] <ttback> no problem
[18:48:01] <ttback> i will prob be tackling this for the week