photoshop-python-api
photoshop-python-api copied to clipboard
formatOptions from JPEGSaveOptions not working.
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?
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
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)