PMXBOT Log file Viewer

Help | Karma | Search:

#pil logs for Tuesday the 10th of March, 2015

(Back to #pil overview) (Back to channel listing) (Animate logs)
[14:15:11] <_russ> hello
[14:15:24] <_russ> I've been here before but haven't seen much activity
[14:15:51] <_russ> I'm running a script that goes through thousands of images (12k so far) and recently one error has started popping up
[14:16:00] <_russ> ValueError: bad transparency mask
[14:16:17] <_russ> this has happened only twice in over 12k runs
[14:17:45] <wiredfool> do you have the images?
[14:18:49] <_russ> sorry was just figuring out how to show line numbers on pycharm, just recently started using it
[14:18:55] <_russ> I don't have the image
[14:19:00] <_russ> but they all come from instagram
[14:19:10] <wiredfool> so, gifs or png?
[14:19:13] <wiredfool> probably
[14:19:17] <_russ> all jpg's
[14:19:29] <wiredfool> ah
[14:19:31] <_russ> I just want to put some code into a pastebin quick
[14:23:14] <_russ> ok I hope this is enough to explain what I'm doing
[14:23:15] <_russ> http://paste2.org/Nngzkhz5
[14:23:55] <_russ> now it's that paste on line 11 that is giving this error: ValueError: bad transparency mask
[14:25:10] <_russ> my first thought is that maybe urllib2.urlopen() isn't returning a proper image?
[14:25:35] <wiredfool> It's likely that the image is messed up in some way.
[14:25:37] <_russ> but I've had that problem elsewhere in my code and PIL returns a different error
[14:25:50] <wiredfool> possibly with wierd exif info that sets somethign in the image.info dictionary
[14:26:09] <wiredfool> as Transparency Mask is something that can be set in exif.
[14:26:19] <_russ> hmm
[14:26:45] <_russ> the fact that I'm getting all my images from instagram makes me think that there is some sort of consistency there
[14:26:45] <wiredfool> also, you have no idea what you're really getting out of the image
[14:26:50] <wiredfool> might be png
[14:26:54] <_russ> that *all* their images would work
[14:27:40] <_russ> I'm pretty certain all avatars on instagram are stored in jpg
[14:27:43] <wiredfool> Maybe.
[14:27:47] <_russ> but if it were in png could that cause this issue?
[14:28:00] <wiredfool> pngs could have transparency already
[14:28:29] <wiredfool> so instead of a mode RGB image, you'd have RGBA or RGB + transparency
[14:28:31] <_russ> and if they did have transparency would that cause this?
[14:29:36] <_russ> I think under normal circumstance a person would take a picture with their phone for their instagram avatar but I guess someone might download an image off the web with transparency and upload that instead of taking a new picture
[14:30:15] <wiredfool> Yep. found the error string.
[14:31:03] <wiredfool> There's a mode mismatch somewhere
[14:31:11] <_russ> in the lib?
[14:31:13] <_russ> or my code?
[14:31:56] <wiredfool> what you're passing in
[14:32:21] <wiredfool> The mask parameter needs to be mode 1, L, RGBA, or RGBa
[14:32:36] <wiredfool> so, in line 11, you're passing in possibly RGB for that
[14:32:49] <wiredfool> no, wait, that's not quite right
[14:33:00] <_russ> well
[14:33:10] <_russ> that particular part I got from googling a LOT
[14:33:15] <_russ> and reading many stack exchange responses
[14:33:39] <_russ> so I just sort of copied what they were doing without fully understanding what was required
[14:33:58] <wiredfool> try this:
[14:34:35] <wiredfool> outerAvatarImage.paste(avatarFile, (5,5), avatarAlpha)
[14:35:25] <_russ> IIRC when I first came across that, what you wrote made more sense to me
[14:35:36] <_russ> but the guy who's comment I was reading did it the way I had it there
[14:35:39] <_russ> and it *DOES* work
[14:35:48] <_russ> but I guess in weird situations like this it doesn't
[14:36:29] <wiredfool> Yeah, it should, since you're promoting it to RGBA in line 10
[14:36:44] <wiredfool> (then again, you don't have to do line 10 if you're passing in the alpha in paste)
[14:37:27] <_russ> oh
[14:37:29] <wiredfool> The other thing that you might want to do is look at image.composite
[14:37:49] <wiredfool> wait, never mind
[14:37:59] <_russ> lol
[14:38:09] <_russ> was just looking it up now
[14:38:10] <wiredfool> you're pasting in at 5,5 and composite basically does that at 0,0
[14:38:28] <wiredfool> alpha composite might do it, but I'd have to check the core on that one
[14:40:13] <_russ> ok well I made the changes you suggested
[14:40:15] <_russ> and it works
[14:40:18] <_russ> thanks for your help, wiredfool
[14:40:19] <_russ> :)
[14:40:41] <_russ> I think I'll write a ValueError catch and log if it ever happens again
[14:40:51] <_russ> but like I said it's only done that twice in over 12k runs
[14:40:52] <wiredfool> yep
[14:40:55] <_russ> so hopefully it's gone
[14:40:57] <_russ> thanks a lot
[14:40:58] <_russ> appreciate it
[14:41:07] <wiredfool> should run slightly faster without the putalpha too
[14:41:18] <_russ> cool :) can always do with more speed :p
[14:41:24] <wiredfool> not that processing is going to take longer than fetching
[14:42:35] <_russ> as it is now I turned off my waits to stay below API call limit
[14:42:40] <_russ> cause the processing can't even go that fast
[14:42:52] <_russ> well for this one particular job
[14:42:58] <_russ> cause the input is so immense
[21:58:04] <travis-ci> benoit-pierre/Pillow#8 (webp - bd4fb9b : Benoit Pierre): The build passed.
[21:58:04] <travis-ci> Change view : https://github.com/benoit-pierre/Pillow/compare/f203564e74c4...bd4fb9b3f9d9
[21:58:04] <travis-ci> Build details : http://travis-ci.org/benoit-pierre/Pillow/builds/53864041