#๐Ÿ”’ create new image from pixel coordinates of another image

579 messages ยท Page 1 of 1 (latest)

dawn sequoiaBOT
#

@real heath

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

real heath
#

hi

#

hii

bronze musk
#

There's a lot of missing information here. What kind of image? What image library are you using? What code have you tried so far?

real heath
#

337x501,120x469,520x603,467x15,447x655,312x161,517x396,403x421,617x335,300x562,419x221,129x78,31x566,22x526,149x124,200x47,146x638,464x227,75x494,399x92,365x308

#

but i want like the pixel

#

the look lot

#

from PIL import Image


img = Image.open('hey.png')


img_resized = img.resize((42, 42))


with open('hey.txt', 'r') as file:

    for line in file:

        coordinates = line.strip().replace(',', ' ').split()
        

        if len(coordinates) != 2:
            
            coordinates = line.strip().split('x')

        x, y = map(int, coordinates)

        img_resized.putpixel((x, y), (255, 0, 0))

# Save the resized image
img_resized.save('output.png')

print("New image saved as output.png")
#

here @bronze musk :>

bronze musk
#

So, you're tyring to save it as 666x666?

real heath
#

no

#

my image size 666x666

#

so i want the 21x21

#

so like

#

337x501,120x469,520x603,467x15,447x655,312x161,517x396,403x421,617x335,300x562,419x221,129x78,31x566,22x526,149x124,200x47,146x638,464x227,75x494,399x92,365x308

#

long but i need the pixel

#

so only one pixe 335x501

#

just like that

#

but only one

#

@bronze musk did you unstertaled?

bronze musk
#

So, you're trying to get a 21x21 pixel out of a 666x666 image?

real heath
#

ya

#

the long

bronze musk
#

Is that a list of all the pixels you're trying to extract?

real heath
#

ya

#

337x501,120x469,520x603,467x15,447x655,312x161,517x396,403x421,617x335,300x562,419x221,129x78,31x566,22x526,149x124,200x47,146x638,464x227,75x494,399x92,365x308,break

#

this one

zenith linden
#

whats the actual grid size of the qr?

#

is there a better way to work with qr other than resizing the image to a grid and reduce it to a bool array?

#

oh wait its not a qr code, my bad

real heath
#

lol

#

it's fine

#

but i need like the pixle

#

only one

zenith linden
#

i've not used pil, but opencv reads images are a numpy array

#

it should be easy to access particular pixels

real heath
#

oh.

#

can you send me ?

real heath
zenith linden
real heath
#

but you can python?

#

it's is ok?

#

i'm new

#

but you can try ?

#

i have opencv

zenith linden
#
import cv2

img = cv2.imread("<path to file>")
#

img should be the array of the image pixels

real heath
#

hmm?

#

can you ?

zenith linden
#

meaning?

#

i did not follow

real heath
#

oh?

#

i mean can you make python?

zenith linden
#

๐Ÿ˜„

#

i cannot make btw

real heath
#

it's is ok?

#

hmm

zenith linden
#

english not your first language?

real heath
#

little english

#

i speak arabic

#

cv2 ?

#

but why?

#

question why the cv2?

#

i just saved like that

zenith linden
#

yes cv2 is opencv's module name

real heath
#

read up

real heath
#

but long

#

this save 21x21

#

i want the save image 21x21

zenith linden
real heath
#

no

zenith linden
real heath
#

no no

#

ya

#

saved

zenith linden
#

resize and save?

zenith linden
real heath
zenith linden
#

cv2.resize should do it

real heath
#

how ?

#

you can send me

zenith linden
#
import cv2
img = cv2.imread("original_image.jpg")
img_resized = cv2.resize(img, (10, 10)) 
cv2.imwrite("new_image.jpg", img_resized)
real heath
#

so txt?

zenith linden
#

original_image is the original image
its being reduced to 10x10

real heath
#

but there txt

zenith linden
#

and written as new image

real heath
#

this txt

#

but i need this 21x21

#

the same

zenith linden
#

what is the txt for though?

real heath
#

this pixel

zenith linden
#

maybe you can explain it in arabic and use a translator?

#

๐Ÿ˜„

real heath
#

Ok, but I want to put pixel in txt, so now if the image is the same

#

bro bad the transalte

#

this different

#

@zenith linden

fathom burrow
#

yo

real heath
#

hiii

fathom burrow
#

you mind explaining what you're tryna achieve?

real heath
#

i want the pixel the size only one

#

so like

#

the one convert the image

#

long

#

337x501,120x469,520x603,467x15,447x655,312x161,517x396,403x421,617x335,300x562,419x221,129x78,31x566,22x526,149x124,200x47,146x638,464x227,75x494,399x92,365x308,break

#

so i need 21x21 save image

#

@fathom burrow

zenith linden
real heath
#

join

#

but you know explain

#

but so many 666x666

#

but i need

#

huh?

zenith linden
#

can't hear you though

real heath
#

huh?

#

i'm hearing of harding

feral temple
real heath
#

yo max

#

@zenith linden dms

#

@feral temple hru?

feral temple
# real heath

im good, are you trying to get a 1x1 pixel from an image?

real heath
#

yes!

#

but long like

#

size

#

but this 21

#

all the 21

#

337x501,120x469,520x603,467x15,447x655,312x161,517x396,403x421,617x335,300x562,419x221,129x78,31x566,22x526,149x124,200x47,146x638,464x227,75x494,399x92,365x308,break

347x477,195x313,423x363,118x361,372x660,100x24,92x526,604x173,593x315,614x479,631x108,637x535,547x127,629x372,363x588,441x356,282x98,28x217,119x250,61x292,279x281,break

433x484,31x440,409x361,483x367,61x405,566x93,453x293,643x135,649x446,476x31,599x344,87x302,147x295,401x360,258x288,305x219,361x479,204x481,284x650,194x335,122x324,break

#

this txt

#

but need save image

#

the pixel

feral temple
#

you want all pixels that are located at either x 21 or located at y21?

#

im having trouble understanding the problem, apologies

real heath
#

yup

real heath
#

337x501 so like the pixel 1x1

feral temple
#

im confused how that has anything to do with the number 21?

feral temple
#

maybe try and use a translator to tranlate what youre trying to say in english. It might make it easier to understand

#

or im missing something here ThinkFish

zenith linden
#

exactly what i told ๐Ÿ˜„

real heath
#

so like

#

only one pixel

#

i want give pixel

#

so next

#

like that

#

so i want the save image 21x21

feral temple
real heath
#

sorry the bad transalate

zenith linden
#

@real heath bro tell what you want to tell in arabic, then use google translator to convert it to english

real heath
#

ู‡ุฐุง ุฎุฑุจุงู† ุชุฑู…ุฌุฉ

zenith linden
real heath
#

max

#

ok so first

#

337x501,120x469,520x603,467x15,447x655,312x161,517x396,403x421,617x335,300x562,419x221,129x78,31x566,22x526,149x124,200x47,146x638,464x227,75x494,399x92,365x308,break

#

but the long

#

But it's a messed up translation, sorry, but I'm sorry. I'm trying this. The first thing is to have a pixel size, but like one dot of a pixel, but because I want a txt of that size.

#

the problem sadly

#

i nkow you confusion ๐Ÿ˜ฆ

#

i hope you unstertaled

feral temple
real heath
#

ya

real heath
#

just only one pixel the 21x21 the txt

#

i need saved image

#

did you unstertaled?

#

@zenith linden

zenith linden
real heath
#

@feral temple you here?

feral temple
#

uh

#

im kinda confused too

real heath
#

should call?

#

dms

feral temple
#

maybe explain your problem to chat gpt and then ask it to translate the problem into english

real heath
#

: (

real heath
#

like save

feral temple
#

no, im saying explain your problem to chat gpt and then tell it to translate the problem youre having into english. Thall make it easier for us to understand and help you :)

real heath
#

i want the save image

feral temple
#

you want to save every single pixel seperately?

real heath
#

maybe

feral temple
real heath
#

i think

#

but maybe this

#

hold on

#

so 35x25 just cut like pixel

#

like only one

feral temple
#

and you want to save that?

real heath
#

so all i need the pixel same the cut

#

ya

feral temple
#

and how will you decide what pixel to save?

real heath
#

like size

#

but the size pixel only on

feral temple
#

so you want to crop the image to a chosen pixel?

real heath
#

yup!

#

mean crop ?

feral temple
#

Cropping an image means cutting out parts of it to make it smaller or to focus on a specific part of the picture. It's like using scissors to cut out the parts of a photo you don't want.

real heath
#

i need this like that cut out

real heath
#

i need for save txt to png 21x21

feral temple
#

what do you mean with txt

real heath
#

337x501,120x469,520x603,467x15,447x655,312x161,517x396,403x421,617x335,300x562,419x221,129x78,31x566,22x526,149x124,200x47,146x638,464x227,75x494,399x92,365x308,break

feral temple
#

?

real heath
#

337x501,120x469,520x603,467x15,447x655,312x161,517x396,403x421,617x335,300x562,419x221,129x78,31x566,22x526,149x124,200x47,146x638,464x227,75x494,399x92,365x308,break
347x477,195x313,423x363,118x361,372x660,100x24,92x526,604x173,593x315,614x479,631x108,637x535,547x127,629x372,363x588,441x356,282x98,28x217,119x250,61x292,279x281,break
433x484,31x440,409x361,483x367,61x405,566x93,453x293,643x135,649x446,476x31,599x344,87x302,147x295,401x360,258x288,305x219,361x479,204x481,284x650,194x335,122x324,break
81x569,535x144,91x303,9x13,585x464,307x181,567x52,281x480,176x224,24x493,63x197,124x324,279x658,514x232,330x129,27x384,253x115,558x353,613x279,80x542,434x487,break
309x377,215x234,546x458,663x456,579x637,355x599,255x511,524x508,169x20,88x346,523x193,365x337,180x35,599x603,293x293,167x176,94x271,220x429,508x456,26x380,73x216,break
662x272,292x563,649x550,291x165,246x572,607x522,585x614,455x423,476x573,347x562,306x419,286x115,173x482,612x598,426x240,359x376,88x564,29x88,344x7,587x367,424x470,break
237x165,461x526,87x197,410x167,554x245,205x257,553x151,296x38,622x84,609x293,194x339,448x472,346x231,131x404,357x232,320x555,597x622,451x391,421x283,418x315,318x169,break
141x303,361x227,224x355,424x151,157x395,146x4,526x525,619x115,135x360,196x448,618x337,569x330,480x571,617x294,262x28,353x96,446x270,449x467,401x414,453x8,169x1,break

#

this txt

feral temple
#

im confused again

real heath
#

bro

#

this like crop

#

337x501,120x469

#

see?

feral temple
#

okay so youre trying to select a pixel, and the dimensions of the selection from the top left to that pixel should be stored in a text file?

real heath
#

yup

feral temple
#

okay, rename the title of this thread to "I'm trying to select a pixel, and the dimensions of the selection from the top left to that pixel should be stored in a text file"

real heath
#

trying to select a pixel, and the dimensions of the selection from the top left to that pixel should

feral temple
#

okay nevermind thats too long of a name lol, change it to Store dimensions of cropped image in text file

real heath
#

Store dimensions of cropped image in text file

#

extract pixels that make txt to image

feral temple
#
def save_pixel_coordinates(x, y, file_path):
    """
    Saves the coordinates of a selected pixel to a text file.

    :param x: The x coordinate of the selected pixel.
    :param y: The y coordinate of the selected pixel.
    :param file_path: The path to the text file where the coordinates will be saved.
    """
    with open(file_path, 'w') as file:
        file.write(f'{x},{y}')

# Example usage
x_coordinate = 50
y_coordinate = 50
file_path = 'your_path'
save_pixel_coordinates(x_coordinate, y_coordinate, file_path)

something like this?

real heath
#

but the txt?

#

where the txt to png?

feral temple
#

you want to create a new QR code that translates the text to an image?

real heath
#

png and txt to png

feral temple
#

?

real heath
#

idk the somethng

feral temple
#

so you want to convert text like "Hello World" to an image?

real heath
#

no

#

look

#

bruh?

#

damn

#

i send dms

feral temple
#

no

real heath
#

;-;

feral temple
real heath
#

this

zenith linden
real heath
#

bro ;-;

#

the pixel cut

feral temple
real heath
#

damn

feral temple
#

im sorry, its the language barrier

real heath
#

this open "hey.png"

feral temple
real heath
#

i hope you unstertaled

#

@feral temple

#

img = Image.open('moredots.png')

with open('hey.txt', 'r') as file:

#

but this like

#

bro not work

#

@feral temple

#

@zenith linden

#

i think ?

#

right?

#

not that

real heath
#

i want the pixel txt to png

#

from PIL import Image

# Open the image
image = Image.open("hey.png")

# Load pixel coordinates from pixel.txt
with open("pixel.txt", "r") as f:
    pixel_coordinates = f.read().strip().split(",")

# Define the size for the cropped image
crop_size = (21, 21)

# Loop through each pixel coordinate and crop the image
for coord in pixel_coordinates:
    if coord == "break":
        continue
    x, y = map(int, coord.split("x"))
    
    # Define a bounding box for cropping
    left = x - crop_size[0] // 2
    upper = y - crop_size[1] // 2
    right = left + crop_size[0]
    lower = upper + crop_size[1]
    
    # Crop the image
    cropped_image = image.crop((left, upper, right, lower))
    
    # Save the cropped image with the pixel coordinate as the filename
    cropped_image.save(f"cropped_{x}x{y}.png")

print("All cropped images saved successfully.")

#

i tired :<

zenith linden
#

Hmm, you want to split the image into 21x21 crop based on the coordinates in the pixel.txt file?

zenith linden
#

Idk, I'm grasping at straws here

real heath
#

like cut

zenith linden
#

You get as many images as there are coordinates in the pixel.txt file?

#

Each image is 21x21 crop of the original image?

real heath
#

yes

#

but like cut pixel

#

did you unstertaled?

zenith linden
#

Maybe I'm not sure though

#

Let me look at pil once, I've not used it

real heath
#

ok

#

@zenith linden ?

zenith linden
#

yep five me a few mins

#

pil is actually pillow?

#

TIL

real heath
#

ok

#

ya

#

pil

zenith linden
#

what error were you getting?

real heath
#

huh?

zenith linden
real heath
#

cropped_image.save(f"cropped_{x}x{y}.png")

#

but no need

#

just the pixel cut

#

1x1

zenith linden
#
from PIL import Image

# Open the image
image = Image.open("hey.png")

crop_size = (21, 21)

# Load pixel coordinates from pixel.txt
with open("pixel.txt", "r") as f:
    for line in f:
        for coord in line.strip().replace("break", "").split(","):
            if coord:
                print(coord)
                x, y = map(int, coord.split("x"))
                # Define a bounding box for cropping
                left = x - crop_size[0] // 2
                upper = y - crop_size[1] // 2
                right = left + crop_size[0]
                lower = upper + crop_size[1]
                # Crop the image
                cropped_image = image.copy().crop((left, upper, right, lower))
                # Save the cropped image with the pixel coordinate as the filename
                cropped_image.save(f"cropped_{x}x{y}.png")

print("All cropped images saved successfully.")
#

try this

real heath
#

wtf

#

bruh?

#

@zenith linden i think this single pixel

zenith linden
#

i don't know what i'm doing at this point

#

if its a single pixel what is 21x21?

real heath
#

hold on let me

zenith linden
real heath
#

this is pixel only one all

real heath
zenith linden
#

why is this relevant for anything i'm not getting at all

real heath
#

look the pixel only one

zenith linden
real heath
#

i thinkt he single pixel

#

oh idk but im new

#

but my bad the crop size wrong

zenith linden
#

what is this for anyway?

real heath
#

which?

zenith linden
#

why is this used for

#

this code

real heath
#

oh

#

chatgpt sob

#

i'm little python

zenith linden
#

no i mean what do you intend to do with this problem?

real heath
#

it's not problem

#

i need help

#

but how the this lik 21x21

#

sorry my bad it's notp crop :<

#

like this

zenith linden
#

ah i give up bro, i'm sorry, i tried but the language is the barrier ๐Ÿ˜

real heath
zenith linden
#

its alright, talk with someone locally

real heath
#

can dms ?

#

why?

#

yoo rep

west shell
#

Let me understand this and I now have a guess. Those are coordinates. You want to save the pixels at those coordinates?

real heath
#

ya

west shell
#

So, each pixel is a tuple containing coordinates?

#

Or you want the value at these coordinates?

real heath
#

no just like cut pixel

real heath
#

and like that

west shell
#

So, you want each pixels to be equal to the value found at those coordinates?

real heath
#

so all the white and block just each like 21x21

west shell
#

That is what cutting a pixel look like

real heath
#

maybe

#

but need all 1x1

#

so look image

#

21x21

west shell
#

Yes, I know they're 1x1 appended together

real heath
#

yup!

#

please

west shell
#

I can't do much with Python in this aspect, but I can be open to PM though for solving this in other language

real heath
#

ok

#

so

#

when

bronze musk
#

Oh, I think I understand now... You have your image with all the pixels in it. The 666x666 image. You are making a new image, and that image will be 21x21. And each pixel in the new image are single pixels cut out from the main picture.

#

and that list there is what pixel from the main image will be in the new image.

bronze musk
#

I'll see what I can do, I'm currently working on a work project, but if anyone else can help you with this, I'm pretty sure that's what you're trying to do now, though.

#

Change topic name to create new image from pixel coordinates of another image.

real heath
#

create new image from pixel coordinates of another image

bronze musk
#

and anyone who jumps in, I can explain what you're trying to do for you.

real heath
#

look up

#

hm?

zenith linden
#

went to have dinner

bronze musk
#

Yeah, this image here #1211284437870968872 message That's how the new image is suppose to look. 21x21, and each pixel is a coord to another pixel from the 666x666 image. the break moves to the next line, which is why the last line doesn't have a break, it's the end of the image.

real heath
#

can you send me code?

zenith linden
#

@real heath do you have numpy installed?

#
import numpy as np
from PIL import Image

image = Image.open("hey.png")
res_image_array = []

with open("pixel.txt", "r") as f:
    for line in f:
        res_image_line = []
        for coord in line.strip().replace("break", "").split(","):
            if coord:
                # print(coord)
                x, y = map(int, coord.split("x"))
                res_image_line.append(image.getpixel((x, y))[0])
        res_image_array.append(res_image_line)

res_image = Image.fromarray(np.array(res_image_array).astype("uint8"))

res_image.save("res_image.png")
#

@bronze musk not too good with pil, this alright?

real heath
#

line 14, in <module>
res_image_line.append(image.getpixel((x, y))[0])
~~~~~~~~~~~~~~~~~~~~~~^^^
TypeError: 'int' object is not subscriptable

bronze musk
#

@real heath Can you send the main image?

real heath
#

wdym?

bronze musk
#

the hey.png image

real heath
west shell
#

this is my result:

real heath
#

why this weird?

zenith linden
#

it becomes this when i run it

west shell
#

your image contains a lot of noises. i'm simply copying pixels from only the coordinates provided in pixel.txt. so, it's like cutting 1x1 and then painting it .

zenith linden
west shell
zenith linden
#

๐Ÿ˜ฎ

west shell
#

yes it is

zenith linden
#

we need answers @real heath

#

๐Ÿ˜„

real heath
#

bro

#

this like that

real heath
bronze musk
zenith linden
#

ya

real heath
#

WHAT?

#

HOW?

#

LOL

zenith linden
#

wtf is happening

real heath
#

send me LOL

zenith linden
real heath
#

OH

#

how did get

#

bruh

#

send me code lol

#

nice job lol

real heath
#

finally thank you โค๏ธ

#

res_image_line.append(image.getpixel((x, y))[0])
~~~~~~~~~~~~~~~~~~~~~~^^^
TypeError: 'int' object is not subscriptable

#

bro?

#
  res_image_line.append(image.getpixel((x, y))[0])
                          ~~~~~~~~~~~~~~~~~~~~~~^^^
TypeError: 'int' object is not subscriptable
zenith linden
#

but what is this

real heath
#

;-;

#

the puzzle lol

zenith linden
#

getpixel is returning a tuple of (r,g,b,a) for me, so just taking the first element

real heath
#

huh?

west shell
#

how was the image generated?

#

to generate a hidden qr code?

zenith linden
#

thats what i want to know too

real heath
#

it's not work ;-;

zenith linden
real heath
#

black

bronze musk
#

It worked for me, so maybe a version difference?

real heath
#

wdym?

zenith linden
#

precognition?

real heath
#

xd

#

it's not work

#

but weird

#

hmm?

zenith linden
#
asttokens==2.4.1
comm==0.2.1
debugpy==1.8.1
decorator==5.1.1
duckdb==0.10.0
executing==2.0.1
ipykernel==6.29.2
ipython==8.22.1
jedi==0.19.1
jupyter_client==8.6.0
jupyter_core==5.7.1
matplotlib-inline==0.1.6
nest-asyncio==1.6.0
numpy==1.26.4
opencv-python==4.9.0.80
packaging==23.2
pandas==2.2.1
parso==0.8.3
pexpect==4.9.0
pillow==10.2.0
platformdirs==4.2.0
prompt-toolkit==3.0.43
psutil==5.9.8
ptyprocess==0.7.0
pure-eval==0.2.2
pyarrow==15.0.0
Pygments==2.17.2
python-dateutil==2.8.2
pytz==2024.1
pyzmq==25.1.2
six==1.16.0
stack-data==0.6.3
tornado==6.4
traitlets==5.14.1
tzdata==2024.1
wcwidth==0.2.13
#

this is what i had in the environment

bronze musk
#
asgiref==3.7.2
Django==5.0.2
numpy==1.26.4
pillow==10.2.0
sqlparse==0.4.4

this is all I had.

real heath
#

wait how i see?

#

what type?

bronze musk
#

pip freeze

real heath
#

so how the update numpy?

bronze musk
#

pip instal numby --upgrade

real heath
#

ty

#

bro not work

bronze musk
#

You're not running the right code. That image isn't 21x21

#

Try saving the file, and re-running the code.

real heath
#

it's is

#

hmm?

#

which ?

bronze musk
#

That file is 733x521

real heath
#

bro

#

it's 21x21

#

wait huh?

bronze musk
#

Show the code you're trying to run.

west shell
bronze musk
#

21x20 isn't 21x21, so you're still running into a problem somewhere.

real heath
#
import numpy as np
from PIL import Image

image = Image.open("hey.png")
res_image_array = []

with open("pixel.txt", "r") as f:
    for line in f:
        res_image_line = []
        for coord in line.strip().replace("break", "").split(","):
            if coord:
                # print(coord)
                x, y = map(int, coord.split("x"))
                res_image_line.append(image.getpixel((x, y)))
        res_image_array.append(res_image_line)

res_image = Image.fromarray(np.array(res_image_array).astype("uint8"))

res_image.save("res_image.png")
bronze musk
#

Yeah, now that you have numpy updated, try the original code again

real heath
#

res_image_line.append(image.getpixel((x, y))[0])
~~~~~~~~~~~~~~~~~~~~~~^^^
TypeError: 'int' object is not subscriptable

#

why the weird?

#
    res_image_line.append(image.getpixel((x, y))[0])
                          ~~~~~~~~~~~~~~~~~~~~~~^^^
TypeError: 'int' object is not subscriptable
#

init?

zenith linden
#

That's earlier, now it should work

real heath
#

hmm?

zenith linden
#

Running the original code gives the error?

real heath
#

res_image_line.append(image.getpixel((x, y))[0])
~~~~~~~~~~~~~~~~~~~~~~^^^
TypeError: 'int' object is not subscriptable

#

bro

#

you can send me txt?

zenith linden
zenith linden
real heath
#

hmm

#

that's weird

#

what happen problem idk whyt?

zenith linden
#

Could be your executing code in a different environment?

#

import os;os.system("pip freeze")

real heath
#

wha?

zenith linden
#

run this

real heath
#

error

zenith linden
#

within the same file and execute it

#

ah windows

real heath
#

ya

#

windows ;-;

zenith linden
real heath
#

huh?

#
annotated-types==0.6.0
asgiref==3.7.2
audioread==3.0.1
av==11.0.0
blis==0.7.11
catalogue==2.0.10
certifi==2023.11.17
cffi==1.16.0
charset-normalizer==3.3.2
click==8.1.7
cloudpathlib==0.16.0
colorama==0.4.6
confection==0.1.4
contourpy==1.2.0
cycler==0.12.1
cymem==2.0.8
decorator==5.1.1
Django==5.0
en-core-web-sm @ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.7.1/en_core_web_sm-3.7.1-py3-none-any.whl#sha256=86cc141f63942d4b2c5fcee06630fd6f904788d2f0ab005cce45aadb8fb73889
ffmpeg==1.4
ffmpeg-python==0.2.0
fonttools==4.46.0
future==0.18.3
greenlet==3.0.3
idna==3.6
imageio==2.33.1
imageio-ffmpeg==0.4.9
iso8601==2.1.0
Jinja2==3.1.2
joblib==1.3.2
kiwisolver==1.4.5
langcodes==3.3.0
lazy_loader==0.3
librosa==0.10.1
llvmlite==0.42.0
MarkupSafe==2.1.3
matplotlib==3.8.3
mendeleev==0.15.0
MouseInfo==0.1.3
mpmath==1.3.0
msgpack==1.0.7
murmurhash==1.0.10
nltk==3.8.1
numba==0.59.0
numpy==1.26.4
opencv-python==4.8.1.78
packaging==23.2
pandas==2.1.4
pillow==10.2.0
platformdirs==4.2.0
pooch==1.8.0
preshed==3.0.9
psutil==5.9.7
PyAutoGUI==0.9.54
pycparser==2.21
pycryptodome==3.19.0
pydantic==2.5.3
pydantic_core==2.14.6
pydub==0.25.1
pyfiglet==0.8.post1
pygame==2.5.2
PyGetWindow==0.0.9
Pygments==2.17.2
PyMsgBox==1.0.9
pyparsing==3.1.1
pyperclip==1.8.2
PyRect==0.2.0
PyScreeze==0.1.30
python-dateutil==2.8.2
pytweening==1.0.7
pytz==2023.3.post1
PyYAML==6.0.1
regex==2023.10.3
requests==2.31.0
scikit-learn==1.4.0
scipy==1.12.0
serial==0.0.97
setuptools==69.0.2
six==1.16.0
smart-open==6.4.0
soundfile==0.12.1
soxr==0.3.7
spacy==3.7.2
spacy-legacy==3.0.12
spacy-loggers==1.0.5
SQLAlchemy==2.0.25
sqlparse==0.4.4
srsly==2.4.8
sympy==1.12
thinc==8.2.2
threadpoolctl==3.3.0
tqdm==4.66.1
typer==0.9.0
typing_extensions==4.9.0
tzdata==2023.3
urllib3==2.1.0
wasabi==1.1.2
weasel==0.3.4
zenith linden
#

looks ok

#

not sure, maybe its an os thing?

bronze musk
#

Try closing the editor and reopening it. Sometimes that helps.

real heath
#

editor?

#

hmmm

#

like this?

regal ivy
#

what are you even trying to do

real heath
#
import numpy as np
from PIL import Image

image = Image.open("hey.png")
res_image_array = []

with open("pixel.txt", "r") as f:
    for line in f:
        res_image_line = []
        for coord in line.strip().replace("break", "").split(","):
            if coord:
                # print(coord)
                x, y = map(int, coord.split("x"))
                res_image_line.append(str(image.getpixel((x, y))[0]))
        res_image_array.append(res_image_line)

res_image = Image.fromarray(np.array(res_image_array).astype("uint8"))

res_image.save("res_image.png")

zenith linden
#

dude try the original code

real heath
#

original code?

zenith linden
#

where is the str coming from?

real heath
#

bro i did but not work

#
import numpy as np
from PIL import Image

image = Image.open("hey.png")
res_image_array = []

with open("pixel.txt", "r") as f:
    for line in f:
        res_image_line = []
        for coord in line.strip().replace("break", "").split(","):
            if coord:
                # print(coord)
                x, y = map(int, coord.split("x"))
                res_image_line.append(image.getpixel((x, y))[0])
        res_image_array.append(res_image_line)

res_image = Image.fromarray(np.array(res_image_array).astype("uint8"))

res_image.save("res_image.png")
regal ivy
#

!d PIL.Image

dawn sequoiaBOT
#

Image Module

The Image module provides a class with the same name which is used to represent a PIL image. The module also provides a number of factory functions, including functions to load images from files, and to create new images.

regal ivy
#

1 sec

real heath
regal ivy
#

what are you even trying to do? x2

bronze musk
regal ivy
#

I meant more about stringing that and getting the first index, but thanks, that helps

bronze musk
#

The code @zenith linden wrote works for him and myself, but not for him

regal ivy
#

image.getpixel returns an int

#

or a tuple if the image is multi layer

zenith linden
#

that doesn't work for him either ๐Ÿ˜

regal ivy
#

can you print the type of image.getpixel?

real heath
#

me?

regal ivy
#

@bronze musk

bronze musk
#

yeah, one second

zenith linden
#

its a tupel of (r,g,b,a) for me

#

could be when the image is sent in discord, it got changed somehow?

regal ivy
#

don't send images in discord

zenith linden
#

i don't see any other possibility

regal ivy
#

they get compressed ๐Ÿคฆโ€โ™‚๏ธ

#

send a zip with the image instead

bronze musk
#

<class 'tuple'>

regal ivy
#

yup that's it

real heath
#

hm?

#

?

regal ivy
real heath
#

zip?

bronze musk
#

I got it, one second.

zenith linden
regal ivy
#

wdym

zenith linden
#

Image.convert("L") should give just the greyscale

regal ivy
#

I can't remember what the formats meant

zenith linden
#

getpixel becomes and int after that

#
import numpy as np
from PIL import Image

image = Image.open("hey.png").convert("L")
res_image_array = []

with open("pixel.txt", "r") as f:
    for line in f:
        res_image_line = []
        for coord in line.strip().replace("break", "").split(","):
            if coord:
                x, y = map(int, coord.split("x"))
                res_image_line.append(image.getpixel((x, y)))
        res_image_array.append(res_image_line)

res_image = Image.fromarray(np.array(res_image_array).astype("uint8"))

res_image.save("res_image.png")

try this

#

make sure to open the res_image.png file after

real heath
#

yay

#

it's works

#

thank you ;D

zenith linden
#

now tell us what the qr means

#

please

real heath
#

huh?

#

why?

#

xd

#

this game puzzle

#

lol

zenith linden
#

how much money are you making for this?

#

๐Ÿ˜„

real heath
#

huh?

#

wdym

#

it's fun puzzle

zenith linden
#

alright, enjoy the rest of the day!!

bronze musk
#

Alright guys, I'm out for a bit, got some running around to do. kitty_wave

#

cya @zenith linden and thank you for your help. even though we will never know what it's for, lol

zenith linden
#

thanks @bronze musk & @regal ivy

real heath
#

Thank cya โค๏ธ

#

how leave?

#

leave

#

!leave

zenith linden
#

!close

#

this

real heath
#

!close

dawn sequoiaBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.