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

Issue In Image Placement Even After Setting Image To Same Size As Layer #244

Open
chetan-SMRI opened this issue Apr 14, 2023 · 1 comment

Comments

@chetan-SMRI
Copy link

chetan-SMRI commented Apr 14, 2023

hello
i am doing same thing , i tried both of your codes, but in my case i am using exactly same image as layer holder,

when i manually do this in photoshop it works fine(i dont have to do any placement because it is exactly as same pixel as layer), but when i do it through the code, the photo becomes more wider than i thought

code i used --

with Session(mockup, action="open",auto_close=True) as ps:
    active_layer = ps.active_document.activeLayer
    bounds = active_layer.bounds
    # in this segment we are getting the frame of mockup, then we use 
    # our function to adjust the image within given pixel without distortion
    width = int(bounds[2] - bounds[0])
    height = int(bounds[3] - bounds[1])
    adjust_image()# i replace my image here with same width and height as layer
    replace_contents = ps.app.stringIDToTypeID("placedLayerReplaceContents")
    desc = ps.ActionDescriptor
    idnull = ps.app.charIDToTypeID("null")
    desc.putPath(idnull, 'img.png')
    ps.app.executeAction(replace_contents, desc)
    ps.active_document.saveAs(f'res.jpg', ps.JPEGSaveOptions())

i am attaching results for reference -
using code -
using code
manually -
manual result
mockup file i used - link

Originally posted by @chetan-SMRI in #38 (comment)

@loonghao
Copy link
Owner

@chetan-SMRI You need to create a new layer, fill it with content, and convert it to a smart object for easy code replacement

relace_image.mp4

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