PS JS script image alignment to Center, left-align.

Hi, I have a PS script that replaces an image layer in the PSD file with an external PNG file. and saves it newly created as a new PNG image.


At the present time, how it works, it aligns the image in the Center within the limits of the previous image.

What I would like is that it aligns left within the limits of the previous image, instead of Center aligning.

Here is the code that I use I think the Center aligns the limits-


[code]

pasted_bounds = psdDoc.activeLayer.Bounds;

flag_width = Number(pasted_bounds[2]-pasted_bounds[0]);

flag_height = Number(pasted_bounds[3]-pasted_bounds[1]);


psdDoc.activeLayer.translate (original_bounds [0] - pasted_bounds [0] + ((original_width-flag_wid th)/2), original_bounds [1] pasted_bounds [1] + ((original_height-flag_height)/2));

[/ code]


Looking forward to the community. Thank you.

In addition, I miss community PS-Scripts and Mike

Here's the complete code in case someone wants to watch-

PS it also replaces a text image using list1.txt, which works very well and I do not understand code for it.

[code]

var repertoire_de_travail = "" / files/work-C / ";"

var image_txt = "list2.txt";

var display_name_txt = "list1.txt";

//----------------------------------COMMON HOUSEKEEPING---------------------------------------------------------

var strtRulerUnits = app.preferences.rulerUnits;

var strtTypeUnits = app.preferences.typeUnits;

app.preferences.rulerUnits = Units.INCHES;

app.preferences.typeUnits = TypeUnits.PIXELS;

app.displayDialogs = DialogModes.NO;

//---------------------------------------------------------------------------------------- --------

-GUIDE OPEN PSD FILE-

guide_file = new File (working_directory + "guide.psd");

If (! guide_file.exists) Window.alert ("not found guide.psd in the working directory");

Open (guide_file);

psdDoc = app.activeDocument;

flagLayer = psdDoc.artLayers.getByName ("ChangeMe2");

shapeLayer = psdDoc.artLayers.getByName ('form 1');

flagLayer.moveAfter (shapeLayer);

flagLayer.move (shapeLayer, ElementPlacement.INSIDE);

Window.Alert (psdDoc.artLayers.Length);

Window.Alert (shapeLayer.Kind);

for (i = 0; i < psdDoc.artLayers.length; i ++) {}

psdDoc.artLayers [i] .visible = false;

}

flagLayer.visible = true;

original_bounds = flagLayer.Bounds;

psdDoc.trim (TrimType.TRANSPARENT, true, true, true, true);

original_width = Number(original_bounds[2]-original_bounds[0]);

original_height = Number(original_bounds[3]-original_bounds[1]);

original_resolution = Number (psdDoc.Resolution);

original_ar = original_width/original_height;

psdDoc.close (SaveOptions.DONOTSAVECHANGES);

-PSD FILE CLOSE GUIDE-

txtfile_text = new File (working_directory + display_name_txt);

Window.Alert (txtfile_text. Open ('r')? ('LIST1:OK': ' list the file not found: names ');

txtfile_image = new File (working_directory + image_txt);

Window.Alert (txtfile_image. Open ('r')? ("LIST2:OK": "file not found: image list");

While (pic_file = txtfile_image.readln ())

{

flag_name = txtfile_text.readln ();

File2 = new File (working_directory + pic_file);

Open (file2);

var picDoc = app.documents.getByName (pic_file);

app.activeDocument = picDoc;

picDoc.trim (TrimType.TRANSPARENT, true, true, true, true);

flag_bounds = picDoc.activeLayer.Bounds;

flag_width = Number (picDoc.Width);

flag_height = Number (picDoc.Height);

flag_ar = flag_width/flag_height;

flag_resolution = Number (picDoc.Resolution);

diff_width = Math.ABS (original_width * original_resolution-flag_width * flag_resolution);

diff_height = Math.ABS (original_height * original_resolution-flag_height * flag_resolution);

picDoc.resizeImage (Number (flag_ar) * Number (original_height), original_height, original_resolution);

} else {}

picDoc.resizeImage (original_width, ((original_width) Number / flag_ar), original_resolution);

}

picDoc.resizeImage (original_width, original_height, original_resolution);

picDoc.selection.selectAll ();

picDoc.selection.copy ();

picDoc.close (SaveOptions.DONOTSAVECHANGES);

-GUIDE OPEN PSD FILE-

Open (new File(working_directory+"guide.psd"));

psdDoc = app.activeDocument;

flagLayer = psdDoc.artLayers.getByName ("ChangeMe2");

psdDoc.activeLayer = flagLayer;

psdDoc.selection.selectAll ();

psdDoc.selection.clear ();

psdDoc.selection.deselect ();

psdDoc.paste ();

pasted_bounds = psdDoc.activeLayer.Bounds;

flag_width = Number(pasted_bounds[2]-pasted_bounds[0]);

flag_height = Number(pasted_bounds[3]-pasted_bounds[1]);

psdDoc.activeLayer.translate (original_bounds [0] - pasted_bounds [0], original_bounds [1] - past ed_bounds [1]);

the vertical alignment

psdDoc.activeLayer.translate (0, original_bounds [1] pasted_bounds [1]); commented 14/01/2009-ISSUE2

psdDoc.activeLayer.translate (original_bounds [0] - pasted_bounds [0] + ((original_width-flag_wid th)/2), original_bounds [1] pasted_bounds [1] + ((original_height-flag_height)/2));

[/ code]

To left justify, using just the first table number in each layer limits:

var leftBoundsOrig = origLayer.bounds[0]
var leftBoundsNew = newLayer.bounds[0]
newLayer.translate(leftBoundsOrig-leftBoundsNew,[enter your code for if you want the height centered here])

Tags: Photoshop

Similar Questions

  • Lightbox widget displays image of hero upper-left instead of Center

    Hello

    For a schoolproject, I worked on creating a Web site in Adobe Muse. Right now I'm trying to create a layout of lightbox to present my work, but the widget shows the hero image in the upper left corner of the page instead of the Center where I like it to be (see screenshot 1 for example).

    Screenshot (252).png

    I use the widget to embed standard Muse with the lightbox parameter (see screenshot 2).

    Screenshot (253).png

    I have several light tables with one image in it because I want the thumbnails to display in various sizes in a random layout on the page. Anywhere on the page I place the image of heroes, it will reappear in the upper left corner to the place where I want to. Anyone know how I can fix this problem? Or maybe know another widget that I could use to do this work? Any help is appreciated !

    Interesting, I am facing a hard time reproducing this behavior with different combinations.

    I would need to check the file for the investigation.

    For once, try to remove the other compositions on the page and check if you see the same behavior that would isolate the question if its because of any element of overlap.

    Thank you

    Sanjit

  • Display images in the top-left-alignemnt

    Whenever I opened a link to an image, there was formerly a top display left aligned page. MaintenantAutres, whenever I open a link to the image, the image appears in the Center-paged-alignment, with gray background. Somene could provide assistance, in order to define the display of the image in the top left alignment?

    Just install https://addons.mozilla.org/en-US/firefox/addon/old-default-image-style/, it should return this change for you.

  • My desktop image has another image in the Center, I can't delete, XP Home Edition

    Image of the desktop has a different image in the Center, I can't delete, XP Home Edition

    Hello

    1 have had modifications made to your computer before the problem occurred?

    2 are you facing this problem that when you set a particular background or with any other images?

    3 is the image pre-installed Windows XP, or you have downloaded the image of a place?

    4. what happens when you try to change the desktop wallpaper. you get the error message?

    I suggest to follow the article below troubleshooting steps and check to see if that fixes the problem on your computer.

    To change your wallpaper

    http://www.Microsoft.com/resources/documentation/Windows/XP/all/proddocs/en-us/display_change_desktop_background.mspx?mfr=true

    I hope this information helps. Please get back to us if you have any other questions on this subject.

  • How to display the image in the center of the imageview window?

    How to display the image in the center of the imageview window, if the image is smaller than the window...

    Page {
        Container {
            layout: DockLayout{}
            verticalAlignment: VerticalAlignment.Fill
            horizontalAlignment: HorizontalAlignment.Fill
            ImageView {
                imageSource: "asset:///images/image.png"
                verticalAlignment: VerticalAlignment.Center
                horizontalAlignment: HorizontalAlignment.Center
            }
        }
    }
    
  • When I try to batch photos to resize in Scripts &gt; Image Processor function, an error message that says: "comand"Pen"is not available. What can I do to fix this?

    When I try to batch photos to resize in Scripts > Image Processor function, an error message that says: "comand"Pen"is not available. What can I do to fix this?

    Yes Adobe tile action fails with the error when he didn't is not the active selection. Note that the Cut Out, built-in frame and thumbnail (selection) after their name. These actions require an active selection to the selected mobile dotted lines before using the action.  Action seeks to soften the selection that were provided to you.  There was no selection, so there is nothing to be flag.

    In addition, the step of the pen in the action of the tile is an interactive step on its dialog box is.  An interactive action defeat as the design of the Image Processor script commands.  Isn't interactivity in a batch.

  • Align the image to the Center...

    Hi to everyone.
    I have a problem with my Web site. I have two images, but if I click on align, Center, or absolute center, nothing, never on the left of the page.
    I try to insert the code html, but nothing. I want to show you the html code:


    < body >

    "< img src ="nuovabarra.jpg"alt =" "width ="1020"height ="170"align ="middle"/ > < br / >

    "< img src ="homepage.jpg"alt =" "width ="1020"height ="595"well ="#Map2"/ >

    Thank you for all the attention.

    align attribute is deprecated. Post a link to your Web page for us help to help you. You can style CSS using floats.

  • Adding to my last question... To keep a background image in the center of the Web page when the browser is shrun

    How do do that?  What is the CSS that makes this work?

    Centers of the background, even when the browser window is smaller or the screen resolution is less, but the content remains stationary in the center of the page: www.signatureweddingsbyjenna.ca

    Hello Jules

    I think that Nancy replied to your question in the other thread.

    I have the site you give as an example, this is the CSS that applies to this image:

    {body
    background - image: URL("page_images/background.jpg");
    bottom-top position: center;
    background-repeat: repeat no.;

    }
    Then of course, it is applied as the context in which theelement, it is placed in the Center and on it and it does not repeat itself.  It is what keeps the central image on the page.  Also helps is that the page is a centered layout.  In the example page that you gave, they have this:
    #page, closure-blocks # {}
    margin-left: auto;
    margin-right: auto;
    Width: 1000px;

    }

    Set the width is important and defining the left/right margin as it means that the browser will allocate the rest of the available space at each margin evently between the two, or put content in the middle.  The only other thing you do is to set the content of the site to the center using
    text-align: center
    It is exlpained herefully.  The only other thing the site has done is put a bit of image information in another element to make it appear that the background image loops in the content.
    Martin
  • resizing image in the center when the click on

    I have a logo with is placed in the middle of the scene, and when I click it, the logo must be resized an amount x pixels in width and height. (see code below)

    sym.$("Logo").animate({"width":"120","height":"40"}, 400); 

    but I want this logo to resize and always stay centered. I feel like I need to add the code related to the center of the alignment, but I don't know how.

    Thanks in advance.

    You can calculate distances, I guess. You can get the position with left(), top() your object, and then the scene and do some math!

  • Merge Image alignment data

    Greetings,

    I turn on this forum, as nothing I've tried has worked.  In a data merge using only images merged in a workbook to Excel CSV, everything is usually the display as I want.  But in one of the frames with a merged image, the images will NOT align to the bottom of the frame.  I tried setting the fitting frame * before * putting the field of image fusion in image.  I tried selecting the preview image and configuration which.  Tried dragging the image. Nothing!  When I toggle the preview to update, it jumps right up to the upper-left corner of the frame.

    I know that this is not the common practice in InDesign.  But any ideas would be appreciated!

    Thank you!

    Bill

    Of course, make sure that all the images are cropped to the same canvas size.

  • Within edge can extend an image from the Center on?

    Ok. I have this picture fuzzy, placed on the edge and I want that it stretch it on the screen.

    I have it. Very easy. However, it develops or extends from the left or right and not from the center outwards.

    I want the image to animate as indicated by these < - image - > arrows (from the Center out).

    I would like that to happen. Any ideas?

    Thank you

    mast

    Here's a sample:

    https://app.box.com/s/83573ytkjkttdwv7zi8b

  • having the image alignment in slide show problem

    THW slide show can be seen here http://www.jimslounge.com/slideshow/bio.swf

    The images are added to a background MovieClip they are set to align to the horizontal and vertical center.  They used to do, but often, they are a little off and sometimes they are way off.  Photos are added tha a Sprite called holder and holder is added to the background MovieClip holderBG the problem is in the displaySlide function.  I noticed that the alignment problem seems to go away when I create a new instance of the holder there but when I do that climates steadly use upper memory with each new slide.

    import com.greensock;
    com.greensock.easing import. *;
    import flash.display. *;
    import flash.utils. *;
    import flash.events. *;
    flash.net import. *;

    var myFont:Font2 = new Font2();
    var externalReq:URLRequest = new URLRequest ("bio.txt");
    var externalLoad: URLLoader = new URLLoader();
    var myFormat:TextFormat = new TextFormat();

    var bars: Bars = new Bars();
    var n: int = 0;
    var intCurrentSlide:int;
    var req:URLRequest;
    var holder: Sprite = new Sprite();
    var holderBG:HolderBG = new HolderBG();
    var loader: Loader;
    var int rand;
    var nxtNum:int;
    var picNum:String;
    var slideCount:int;
    var xmlLoader:URLLoader;   Slideshow xml loader
    var xmlSlideshow:XML;  Slideshow xml
    var strXMLPath:String = 'bioPics-"Data.xml" ';
    var slideName:String;
    history of the var: Array = new Array();
    var duration: number =. 5;
    var prevSlide:String;
    var timeline:TimelineMax;


    addChild (holderBG);
    holderBG.x = stage.stageWidth / 2 - holderBG.width / 2;

    xmlLoader = new URLLoader();
    xmlLoader.addEventListener (Event.COMPLETE, onXMLLoadComplete);
    xmlLoader.load (new URLRequest (strXMLPath));
    ///////////// text setup ////////////////////
    myFormat.font = myFont.fontName;
    myFormat.size = 14;
    myFormat.leading = 2.5;

    bioText.setStyle ("textFormat", myFormat);
    bioText.setStyle ("IncorporerPolices", true);
    bioText.textField.alpha = 1;

    externalLoad.load (externalReq);
    externalLoad.addEventListener (Event.COMPLETE, textReady);
    /////////////text setup////////////////////////
    createTimeline();

    function textReady(event:Event):void {}
    bioText.htmlText = event.target.data;
    }
    function onXMLLoadComplete(e:Event):void {}
    xmlLoader.removeEventListener (Event.COMPLETE, onXMLLoadComplete);
    xmlSlideshow = new XML (e.target.data);     create new code xml with the data received
    slideCount = xmlSlideshow... image.length ();   get the total number of slides
    loadSlide();
    }

    function loadSlide (): void {}
    prevSlide historical = [history.length - 1];
    RAND = Math.ceil (Math.random () * slideCount - 1);
    loader = new Loader();
    req = new URLRequest (xmlSlideshow.. @src [rand]);
    loader.contentLoaderInfo.addEventListener (Event.COMPLETE, displaySlide);
    Loader.Load (req);
    slideName = xmlSlideshow... @src [rand] m:System.NET.SocketAddress.ToString ();
    }

    function createTimeline (): void {}
    Timeline = new TimelineMax ({repeat: 1, repeatDelay:5, onComplete:loadSlide, suspended, yoyo: true: true});
    for (var int count = 1; count < = 10; count ++) {}
    var mc:MovieClip = bars ["bar" + count];
    Timeline.Append (TweenMax.from (mc, duration, {x: "64", alpha: 0, ease:Cubic.easeOut}), -. 4);
    }
    }

    function displaySlide(e:Event_=_null):void {}
    loader.contentLoaderInfo.removeEventListener (Event.COMPLETE, displaySlide);
    / / holder = new Holder();  If I lose the alignment problem but gain a menory problem.
    If (holder.numChildren > 0) {holder.removeChildAt (0) ;}}
    holder.addChild (loader.content);
    / / Center of the photo
    Holder.x=holderBG.width/2 - holder.width/2;
    Holder.y=holderBG.height/2 - holder.height/2;

    make the position of the mask on the peak
    bars.x = Holder.x;
    bars.y = Holder.y;
    bars.cacheAsBitmap = true;

    holder.cacheAsBitmap = true;
    Holder.Mask = bar;
    bars. Width = holder.width;
    bars. Height = holder.height;
    holderBG.addChild (holder);
    holderBG.addChild (bars);
    Timeline.Restart ();
    }

    Sorry my bad I mean this

    holderBG.removeChild (holder);

  • OFF Auto placing the image in the upper left corner of the scene

    Can someone help, I'm a logo on the stage using a load button, the command is

    I managed to call in an image in the folder of the image using a button, but it is placed in the upper left corner.

    1 button using:
    on (release) {}
    loadMovie ("images\\logo1.jpg", 1);
    unloadMovieNum (2)
    }

    I want to make sure that when I press the button using the ACE over the image is at the center of the screen
    the stage size is 800 x 600

    ANY IDEAS GUYS

    Flash will put any new content loaded in the upper left corner, the point (0,0), if you do not give a location. The simplest solution is to use a movieClip.

    1. create a new movieClip in the library. Don't give him any content.
    2. drag an instance of this empty movieClip on the stage at the location where you want the content loaded to show.
    3. This movieClip instance name empty.
    ("4 load in new content to this clip: clipName.loadMovie("images\\logo1.jpg ");
    5 adjust the position of the empty clip on the stage as needed.

  • image align = middle

    now that I can actually post my question...

    I want to have a picture on the left of a few lines of text with text vertically aligned in the middle of the image. If I < img align = "middle" >, it doesn't line up to the first line of text and puts the rest under the image. It has been awhile, but I could have loaned oath I've done this before and had all the text lines up next to the image, not only the first line (of course, I could think of another program or something), but now I can't seem to find a way to do it.

    I know that I can get all the text next to the image if I align = left, but there is an empty space under the text and I'd rather have lined up in the middle of the image, because it would just look better in this case. I also know that I can put the margins or padding on the text, but I don't know how much I put pass in the middle (I'm sure it would be just a little trial and error until I got it looking right), or if she wishes to law in all the different browsers.

    so, my question is basically this: what is the best way to get more than one line of text to align vertically in the middle of an image? so far, I just had recourse to the use of an array of two cells with each other vertically-aligned way. and that could be the best way to do it, as far as I know! I just want to know if there is a better way before that I continue to do it as I am.

    Thanks in advance for any help!

    -courtney

    Show us your code, Courtney, please.

    --
    Murray - ICQ 71997575
    Adobe Community Expert
    (If you * MUST * write me, don't don't LAUGH when you do!)
    ==================
    http://www.dreamweavermx-templates.com - template Triage!
    http://www.projectseven.com/go - DW FAQs, tutorials & resources
    http://www.dwfaq.com - DW FAQs, tutorials & resources
    http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
    ==================

    'c h n' wrote in message
    News:fdr6me$Q05$1@forums. Macromedia.com...
    > now that I can actually post my question...
    >
    > I want to have an image on the left of a few lines of text with the text
    > vertically aligned in the middle of the image. If I do<>
    > align = "middle" >, he
    > only aligns the first line of the text and puts the rest under the image.
    > she
    > been awhile, but I could have sworn I did this before and all had
    > of
    > line of text up next to the image, not only the first line (of course, i).
    > may
    (> be thought of another program or something), but now I can't seem to
    > find a way to do it.
    >
    > I know that I can get all the text next to the image if I
    > align = left,
    > but there is an empty space under the text so I'd rather have aligned
    > to
    > in the middle of the image because it would just look better in this
    > individual
    > instance. I also know that I can put the margins or padding on the text, but I
    > don't know how much I need to go in the middle (I'm
    > sure it
    (> would be just a little trial and error until I got it looking right), or
    > If it wants that right in all the different browsers.
    >
    > so my question is basically this: what is the best way to get more than
    > a
    > line of text to align vertically in the middle of an image? so far, I have
    > just
    > resorted to a table of two compartments with each one vertically
    > aligned way. and
    > could be the best way to do it, as far as I know! I just want to know
    > If
    > there is a better way before that I continue to do it as I am.
    >
    > thank you in advance for any help!
    >
    > - courtney
    >

  • I lost my desktop background on image and I'm left with one blank screen other than the icons

    I am a user of Skype and when I go on Skype I lose my background image the top desktop icons on the desktop are always there but except that I have now a screen empty, I had this back by a movement of system restore but I have now lost the image again using Skype again! How to solve this problem?

    Hi RaymondManley,

    1. did you of recent changes on the computer?

    2 when was the last time it was working fine?

    3 return the wallpaper if you close the Skype program on the computer?

    4. do you have security software installed on the computer?

    Method 1

    It is possible that some third-party programs installed on the computer is causing the problem.

    I suggest that you put the computer in a clean boot state and check if it helps.

    To help resolve the error and other messages, you can start Windows XP by using a minimal set of drivers and startup programs. This type of boot is known as a "clean boot". A clean boot helps eliminate software conflicts.

    See the link below to learn more about how to clean boot.

    How to configure Windows XP to start in a "clean boot" State

    http://support.Microsoft.com/kb/310353

    Reset the computer to start as usual

    When you are finished troubleshooting, follow these steps to reset the computer to start as usual:

    (a) click Start, type msconfig in the search box and press ENTER.

    (b) If you are prompted for an administrator password or for confirmation, type your password or click on continue.

    (c) under the general tab, click the Normal startup option, and then click OK.

    (d) when you are prompted to restart the computer, click on restart.

    Method 2

    If the previous step fails, then I suggest that reduce you the hardware acceleration on your computer and check if it helps.

    (a) click Start, click run, type desk.cpl, and then click OK.

    (b) click on the settings tab and then click Advanced.

    (c) in the performance tab or on the Troubleshooting tab, move the Hardware Acceleration slider to the left to reduce the acceleration.

    (d) click OKand then click close.

    (e) If you are prompted to restart your computer, click Yes.

Maybe you are looking for