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

formatOptions from JPEGSaveOptions not working. #197

Open
xagonyx opened this issue Oct 28, 2022 · 2 comments
Open

formatOptions from JPEGSaveOptions not working. #197

xagonyx opened this issue Oct 28, 2022 · 2 comments

Comments

@xagonyx
Copy link

xagonyx commented Oct 28, 2022

Foremost, I want to thank you for this incredible library. I have a simple question, I'm trying to save a JPEG file, but I'm having trouble setting the format to Progressive, here's my code:

from photoshop import Session
from photoshop.api._core import Photoshop
from photoshop.api.enumerations import MatteType
from photoshop.api.enumerations import FormatOptionsType

with Session(jpegpath, action="open") as ps:
	resolution_str = ps.active_document.resolution
	change_size = ps.active_document.resizeImage(new_width, new_height, resolution=resolution_str, automatic=8)
        save_as = ps.active_document.saveAs(copy_path, ps.JPEGSaveOptions(quality=12, embedColorProfile=True, matte=MatteType.NoMatte, formatOptions=FormatOptionsType.Progressive), asCopy=True)

However, I'm getting the following error:

Traceback (most recent call last):
  File "D:\Image_size.py", line 9, in <module>
    ps.JPEGSaveOptions(quality=12, embedColorProfile=True, matte=MatteType.NoMatte, formatOptions=FormatOptionsType.Progressive), asCopy=True)
TypeError: __init__() got an unexpected keyword argument 'formatOptions'

What am I doing wrong?

@Bellec-creator
Copy link

the argument 'formatOption' does't existe.

JPEGSaveOptions(quality=5, embedColorProfile=True, matte=MatteType.NoMatte)

ref = https://loonghao.github.io/photoshop-python-api/reference/photoshop/api/save_options/jpg/#photoshop.api.save_options.jpg.JPEGSaveOptions

@Investigamer
Copy link
Contributor

You can't pass formatOptions as a parameter, you have to set it after the instance is created, so just break that line up like so:

jpeg_options = ps.JPEGSaveOptions(quality=12, embedColorProfile=True, matte=MatteType.NoMatte)
jpeg_options.formatOptions = FormatOptionsType.Progressive
save_as = ps.active_document.saveAs(copy_path, jpeg_options, asCopy=True)

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

3 participants