Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change color of generated PNG Question #137

Open
MaveCritDev opened this issue Jan 4, 2022 · 3 comments
Open

Change color of generated PNG Question #137

MaveCritDev opened this issue Jan 4, 2022 · 3 comments

Comments

@MaveCritDev
Copy link

Hello!
Firstly: Happy new year and thank you very much for this library. Right now, this is the only one I was able to find on the whole web.
Please excuse any dumb mistakes. Actually this is my first ever python project. And now I have a question about this :)

Probably its best if I just explain briefly what I'm trying to achieve and what I already have:
We do embroidery for endusers. They can send us their dst files but right now we have to call them after to clarify every color we should use. I want to automate this a bit.

What I have
I made a simple react frontend in which the users can upload their dst files. After the upload I call a pyembroidery script on the backend to generate a png preview of this file. Since DST does not contain any color informations I initially transform it to a PES.
After that I generate a initial preview PNG of the PES and send the informations of pattern.threadList() back to the frontend.
Now in the frontend the user is able to adjust the threadcolors using the threadList of the previously generated pes file.

What I'm trying to achieve
Use the hexa values the user selectes in the frontend and update the PES file to generate a new PNG with provided colors.
So lets say the original .threadList() is:
[EmbThread(thread='#00000', description='Magenta', catalog_number='7', brand='Brother', chart='Brother'), EmbThread(thread='#FFFFF', description='Mint Green', catalog_number='10', brand='Brother', chart='Brother')]
And my new hexa colors array looks like this: ['#238636', '#433636']

How can I override the threadList?
Something like threadList()[0].thread = newThreadColors[0]
(The descriptions and all other thread infos are not relevant to me since the file is only used to generate a preview PNG)
Is this possible?

Again sorry, I never touched Python yet. Probably its super simple but I'm just not knowing it.

Thank you very much for every help, I appreciate :)

Greeting from Germany,
Philipp

@tatarize
Copy link
Contributor

tatarize commented Jan 4, 2022

To change the value in thread 0 you would call:
pattern.threadlist[0].set_hex_color('#238636')

And for thread 1:
pattern.threadlist[1].set_hex_color('#433636')

@tatarize
Copy link
Contributor

tatarize commented Jan 4, 2022

Notably this isn't covered in the readme, so it is an oversight on my part.

@MaveCritDev
Copy link
Author

Thank you very very much!
With your help I was able to generate and update preview files exactly how I wanted it!
It might be a bit nested & somehow messy since I fire a POST to a SpringBoot backend which then calls the python script using processbuilder but thats the only solution I could come up with (Every color change also needs to be updated in the db)

I already said it and I will repeat it with joy: Thank you for your work.
(And also I want to note that I'm amazed how fast you answered.)

Thank you!

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants