|
hmmmm app is saying it cant find a file: pre:PIL.UnidentifiedImageError: cannot identify image file '227624av.png'
|
# ? Jun 2, 2021 23:50 |
|
|
# ? Jun 8, 2024 13:25 |
|
no wait it can find it but not identify it hmm this is how the image is being created btw pre:avatarImage = userProfile.select_one('.userinfo .title').find('img') avatarURL = (avatarImage.attrs['src']) avatarFile = f'{horribleJerk}av.{avatarURL.split(".")[-1]}' avatar = requests.get(avatarURL, cookies=authCookies, headers=headers) print(str(avatar.status_code)) if avatar.status_code == 200: with open(avatarFile, 'wb') as avFile: avatar.raw.decode_content = True shutil.copyfileobj(avatar.raw, avFile)
|
# ? Jun 2, 2021 23:59 |
|
Did you write to the file and not close it or something?
|
# ? Jun 3, 2021 00:02 |
|
mystes posted:Did you write to the file and not close it or something? no, with open automatically closes the file when it unindents
|
# ? Jun 3, 2021 00:03 |
|
Yeah I didn't actually read your code. Maybe print the file size or otherwise make sure it's writing a valid image though.
|
# ? Jun 3, 2021 00:04 |
|
Also are you really supposed to use response.raw? I think it might break in some situations.
|
# ? Jun 3, 2021 00:08 |
|
mystes posted:Also are you really supposed to use requests.raw? I think it might break in some situations. i have no idea how else to download an image when all i have is the image link via a script
|
# ? Jun 3, 2021 00:09 |
|
code:
|
# ? Jun 3, 2021 00:16 |
|
mystes posted:
eh ill give it a shot
|
# ? Jun 3, 2021 00:17 |
|
a quick thing to do is just less the supposed png file and discover that the contents is actually a 404 page or some such.
|
# ? Jun 3, 2021 00:19 |
|
You don't even need to be logged in to access avatars, it seems, so you can just do something like this to test it:code:
|
# ? Jun 3, 2021 00:20 |
|
alright well im out of ideas for how to download an image from the link cos i can get the link, ive tested that, but i dont know how to download the image Cybernetic Vermin posted:a quick thing to do is just less the supposed png file and discover that the contents is actually a 404 page or some such. considering it only writes a file if its 200 then i dont think thats the case
|
# ? Jun 3, 2021 00:22 |
|
hbag posted:alright well im out of ideas for how to download an image from the link
|
# ? Jun 3, 2021 00:23 |
|
mystes posted:Did the thing I suggested a minute ago not work? Because it works for me with a hardcoded url. testing that now, think it might
|
# ? Jun 3, 2021 00:23 |
|
alright i think that worked now to figure out how to use pillow to paste one image ontop of another and then save it
|
# ? Jun 3, 2021 00:31 |
|
Asleep Style posted:cisco stu here with some good news about VOIP adoption trends lol
|
# ? Jun 3, 2021 01:00 |
|
Smythe posted:update this: https://chrome.google.com/webstore/detail/sa-needful/bipfbhacdgoojjfblifgjadhabepbekm please!
|
# ? Jun 3, 2021 01:01 |
|
i uh what how
|
# ? Jun 3, 2021 01:14 |
|
hbag posted:i uh wherever you are, there is the worst programmer
|
# ? Jun 3, 2021 01:15 |
|
rotor posted:hbag, are you familiar with nntp lol
|
# ? Jun 3, 2021 01:51 |
|
you can tell from my commit messages alone exactly where i figured out a thing i was trying to do
|
# ? Jun 3, 2021 02:00 |
|
euuuuurrrghh alright im still trying to figure out how to test if the entire image is just transparent and nothing else
|
# ? Jun 3, 2021 02:23 |
|
on: too many redirects: make sure you're consistently sticking with https for all requests. you can snowball a bad http request into too many redirects if, like, somethingawful, you use a lovely garbage CDN like NaziCache-sorry, Cloudflare
|
# ? Jun 3, 2021 02:35 |
|
Jonny 290 posted:on: too many redirects: make sure you're consistently sticking with https for all requests. you can snowball a bad http request into too many redirects if, like, somethingawful, you use a lovely garbage CDN like NaziCache-sorry, Cloudflare yea i figured it out i was accidentally sending it auth cookies that were None so the php was making GBS threads itself fixed that poo poo now though NOW what need to do is figure out how to detect if an entire image is just one big transparent space my reasoning for this is so i can detect if someone's doing a tall gangtag av (like mine) and then, if they are, just use the first image gangtag in place of their avatar
|
# ? Jun 3, 2021 02:38 |
|
hbag posted:NOW what need to do is figure out how to detect if an entire image is just one big transparent space
|
# ? Jun 3, 2021 02:42 |
|
mystes posted:You can just iterate through the pixels and check the alpha value, but unless people are using giant transparent avatars maybe you should just check whether the avatar is like 5x5 or smaller? i thought putting loops inside loops was a bad idea this part of the code is already in a while loop, sticking a for loop in it is gonna be 2 loops
|
# ? Jun 3, 2021 02:51 |
|
mystes posted:You can just iterate through the pixels and check the alpha value, but unless people are using giant transparent avatars maybe you should just check whether the avatar is like 5x5 or smaller? yeah and because this problem is embarrassingly parallel you can parallelize it for efficiency, each “process” only needs to check one pixel each and your result is still accurate code:
|
# ? Jun 3, 2021 02:52 |
|
fart simpson posted:yeah and because this problem is embarrassingly parallel you can parallelize it for efficiency, each “process” only needs to check one pixel each and your result is still accurate having a hard time breaking down your snippet into "what bit is doing what" but that might be because its 3 am and im tired obviously im still not gonna say no to a more basic explanation because i will take that every time i apparently need things explained to me with small words because my brain is a collander
|
# ? Jun 3, 2021 02:55 |
|
hbag posted:i thought putting loops inside loops was a bad idea it's not slow, it's readable
|
# ? Jun 3, 2021 03:01 |
|
hbag posted:i thought putting loops inside loops was a bad idea Fart simpson is just trying to make everything complicated. You can probably just do something like: code:
Also this might not handle gifs if people still use gifs, because they're indexed color and I don't care enough to check whether they are treated as a different color mode by pillow.
|
# ? Jun 3, 2021 03:06 |
|
mystes posted:Probably whoever said nesting loops was bad was talking about stuff like looping over a huge list in the inner loop of a nested loop which will be executed a zillion times, when you could just be using a hashtable or something, and not looping over the x and y coordinates of a tiny image. alright, ill give this a try in the morning rn its 3 am so im going to bed lol
|
# ? Jun 3, 2021 03:12 |
|
mystes posted:Fart simpson is just trying to make everything complicated. i already posted a link to the pillow docs for the built in method that tells you the min and max pixel values for an entire band of the whole image seems pretty simple and useful here to me
|
# ? Jun 3, 2021 03:16 |
|
fart simpson posted:i already posted a link to the pillow docs for the built in method that tells you the min and max pixel values for an entire band of the whole image seems pretty simple and useful here to me i couldn't find the post when i was scrolling through em which is why i asked again tbh
|
# ? Jun 3, 2021 03:19 |
|
fart simpson posted:i already posted a link to the pillow docs for the built in method that tells you the min and max pixel values for an entire band of the whole image seems pretty simple and useful here to me
|
# ? Jun 3, 2021 03:23 |
|
i've never bought one of those big avatars. are you saying it's required to upload a tiny one as your "real" avatar? i always thought you just put bbcode into the text and didn't have a regular avatar.
|
# ? Jun 3, 2021 04:10 |
|
fart simpson posted:yeah and because this problem is embarrassingly parallel you can parallelize it for efficiency, each “process” only needs to check one pixel each and your result is still accurate this poo poo is why i gave up trying to learn Coding. what the gently caress is this
|
# ? Jun 3, 2021 04:42 |
|
Jonny 290 posted:this poo poo is why i gave up trying to learn Coding. what the gently caress is this an exciting way to turn a simple problem into a worse, more complex, problem
|
# ? Jun 3, 2021 05:25 |
|
Jonny 290 posted:this poo poo is why i gave up trying to learn Coding. what the gently caress is this okay so the code assumes you have a 1-dimensional list that has all the pixel values of your av image. it defines a function that tells you if the image is transparent or not, and then starts a (lightweight thread, i think is the default?) pool of executors that each take a single entry in that list and calculate if that pixel is opaque or transparent, and then the all() (iirc) tells you if any of them are opaque the use of the map function there is some unintuitive stuff to newcomers — you’re not calling the is_transparent function in that map line. you’re passing the function itself in as an object that then gets called by map() with the proper alpha array entry for each one in the list. i can never remember what the technical cs term for it is but it’s one of those things that broke my mind when i learned ruby from a codebase full of people who loved map and filter and the like. Smythe posted:update this: https://chrome.google.com/webstore/detail/sa-needful/bipfbhacdgoojjfblifgjadhabepbekm rip vine
|
# ? Jun 3, 2021 05:36 |
|
Bloody posted:an exciting way to turn a simple problem into a worse, more complex, problem it turns a simple problem into a steady paycheck
|
# ? Jun 3, 2021 05:38 |
|
|
# ? Jun 8, 2024 13:25 |
|
hbag posted:having a hard time breaking down your snippet into "what bit is doing what" but that might be because its 3 am and im tired you say this every time you post, lol
|
# ? Jun 3, 2021 05:42 |