EmilDohne / PhotoshopAPI

A modern and performant C++20 read/write parser of Photoshop Files (*.psd and *.psb) with fully fledged Python bindings hosted on PyPi
https://photoshopapi.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
94 stars 9 forks source link

How to modify the drawing board size of PSD #81

Closed kkgg0521 closed 3 months ago

EmilDohne commented 3 months ago

Hey, I assume this is a duplicate of the last ticket which ive translated from chinese? In which case I would delete the other one since it is not in english.

As for your question, if by drawing board you mean the canvas itself theres multiple options, you can either modify it on initialization using the appropriate constructor or directly modify the properties after construction if you wish to resize it after adding all the layers

Here is the relevant cpp reference https://photoshopapi.readthedocs.io/en/latest/code/layeredfile.html The attributes for cpp are m_Width and m_Height

Here is the relevant python reference https://photoshopapi.readthedocs.io/en/latest/python/layeredfile.html The attributes for python are width and height

Hope this helps!

kkgg0521 commented 3 months ago

this is my code ` import psapi

layered_file = psapi.LayeredFile.read("LR8224.psd")

print(layered_file.width) layered_file.width = 500 layered_file.height = 500

layered_file.write("123.psd") `

kkgg0521 commented 3 months ago
layered_file = psapi.LayeredFile.read("LR8224.psd")
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd5 in position 24: invalid continuation byte

EmilDohne commented 3 months ago

Let me have a look once im home! Is there any way you could provide me with the file in question if it is not confidential.

That being said I recently pushed a change that fixed a bug relating to filepaths where reading a file without a path would fail.

You could try instead psapi.LayeredFile.read("./LR8224.psd")

I think this should fix your error but let me know if it doesnt. This bugfix will be part of the 0.5.0 release once I get the time to implement some other features :)

@kkgg0521

kkgg0521 commented 3 months ago

thank you very much . can you give me you email?

EmilDohne commented 3 months ago

Yes sure, its emildohne@gmail.com :). Ill try and have a look tonight or tomorrow morning my time!

EmilDohne commented 3 months ago

Hey @kkgg0521 I gave a look at the file and was able to read it just fine using the latest pip installable photoshopapi version of 0.4.0 without any errors. Even when omitting the "./" prefix from the path I only got a create_directories error and not a UnicodeDecodeError.

Mind letting me know what python version and PhotoshopAPI version you are running? That way I can see if I can recreate your setup.

Additionally if you could let me know what OS you are running on that could help :)

kkgg0521 commented 3 months ago

python 3.7 PhotoshopAPI 0.4.0 win11

kkgg0521 commented 3 months ago

我切换了电脑 发现正常读取了。

kkgg0521 commented 3 months ago

这个问题解决了 希望可以早日用上0.5.0版本的软件 感谢

EmilDohne commented 3 months ago

Glad it worked out, in general something that is TODO is the parsing of unicode layer names as I hadnt implemented that yet whicv is why your layer names might come out funny.

Ill open an issue for it

kkgg0521 commented 3 months ago

这个项目我很感兴趣,他十分强大。