Create Pattern Swatch from Placed Image in Javascript

I need to create a large number of pattern swatches from some .jpg file on disk. I've figured out how to script the insertion of the .jpgs into my AI document as placed images:
     // Embed the image into the document.
     file = new File("MyImage.jpg");
     var document = app.activeDocument;
     var newPlaced = document.layers["swatches"].groupItems.createFromFile(file);
     newPlaced.name = "MyImage_Placed";
This works fine and the item shows up in the correct layer as an embedded image.
Now I want to create a PatternSwatch (I think) from that Image.
To create a new swatch the code starts out as:
     newSwatch = document.swatches.add();
     newSwatch.name = "MyImage_Swatch";
but now I'm stuck! How do I associate the new PlacedItem with the swatch I just created? I can see the swatch in the palette so I'm partway there.

When you say you would drag the image itself into the Swatch Palette and it would show the image itself? How would then use this swatch? Can you give an example of what you would apply a jpeg to as a swatch? The only palette that I can think of off the top of my head that you can drag a jpeg into and have the icon appear as the jpeg is the Symbols Palette. Is is possible that you were using the Symbols Palette in the past and not the Swatch Palette?

Similar Messages

  • Pattern Swatch From Pattern Maker Filter

    Is there a way to copy a new custom Pattern Swatch that you create using the Pattern Maker filter? I have often created a pattern that worked perfect but could only apply it to a layer. I want to be able to save just the custom swatch that patterns correctly so that I can use it as a repeating background image on a website.
    I know I should know this, but it's something that I've never been able to figure out, or find in the Help Menu.
    Linda

    > Well, you could always open a new file the same size as the pattern you created originally and load it from the Layer Styles > Pattern dialog.
    For some reason it tiles right when I apply the pattern to a large background. But when I attempt to create a simple square tile, even the same size as I started with, and attempt to use it as a repeating background on a web page, you can see the tiling.
    > Or how about after you make a new pattern in Pattern Maker and OK it, you have it load into an open Photoshop window, yes? You know the size of the tile the pattern maker made. How about making a selection the same size and use the arrow keys to move it into place and then copy/paste a new doc.
    Sounds good on paper Welles. But I can't get it to work right. I still see the tiling when I save the file out this way and use it as a background.
    I don't need this for anything urgent. And I know I can make something work for when I need it. The pattern I'm working with has a lot of texture so when it repeats outside of applying it in Photoshop, it just doesn't match up right. I had hoped there would be an easy way to capture the custom Pattern Maker Tile as a single image that could be used to repeat itself without seeing the tiling.
    Maybe this would be a good feature request. Thanks for both of your input.

  • Center-align created pattern swatch

    Hi there
    When creating patterns with for example very easy dimensions like the artboard 400 x 400 px etc, and everything right placed, as you can see on the print screens, after having created the pattern, it never aligns center-aligned like I would like it too. Very annoying.
    who can help? Thanks!!
    Left: the original positioning before creating the pattern.
    Right: the result of a perfect square, center aligned to the artboard and with the swatch applied, not too pretty he?

    Hi CarlosCanto
    You're right. So far so good, but this still doesn't help me getting a nice pattern centered on the artboard?
    The image here is an example of the actual pattern I would like to use The smaller image is a print screen of the actual composition of elements in Illustrator which I made the pattern of.
    Is there an easy solution for this?
    Thanks!

  • Automatic Pattern creation from Input Image

    Hi all,
    I've created a program to automatically create a patterns from an input image
    1. The user selects image
    2. with a rectangle he selects a zone of that image
    3. An automatic pattern image is created as result of repeating that rectangle
    It's working most of the times but sometimes:
    1. The red rectangle which I use to select the area I want to repeat is not displayed
    2. The area is not correctly handled and strange blank areas appear
    Do you know how to solve these issues?
    I put you here the whole source code so you can execute it and have fun creating patterns!
    http://tlloreti.googlepages.com/src.rar
    Regards
    T

    Part 2*
    Now, about your red rectangle
    class Selector extends MouseInputAdapter
        ImageSelectionPanel selectionPanel;
        Point start;
        Point end;
        boolean dragging, isClipSet;
        public Selector(ImageSelectionPanel isp)
            selectionPanel = isp;
            dragging = false;
            isClipSet = false;
        public void mousePressed(MouseEvent e)
            if(isClipSet)             // clear existing clip
                selectionPanel.setClipFrame(start, start);
                isClipSet = false;
            else                      // or start new clip
                start = e.getPoint();
                dragging = true;
                isClipSet = true;
        public void mouseReleased(MouseEvent e)
            dragging = false;
            end = e.getPoint();
            System.out.println("START="+start);
            System.out.println("END="+end);
            int width=(int) (end.getX()-start.getX()) ;
            int height=(int) (end.getY() - start.getY());
            if ((width>0)  && (height>0))
            MergeImages.GenerateFourImagesDragAndDrop(crop1.fileName, start.getX(), start.getY(),width ,height );
        public void mouseDragged(MouseEvent e)
            if(dragging)
                selectionPanel.setClipFrame(start, e.getPoint());
    }The problem stems from the isClipSet and dragging variables. I have no idea what you were trying to achieve with these. I'm guessing you're making certain assumptions about the way mouse events are received that are just plain wrong. Also, the logic in the MouseReleased method is wrong. The point you define as "start" is not necessarily the top left of the clip rectangle as you have it set up. But in this call
    MergeImages.GenerateFourImagesDragAndDrop(crop1.fileName, start.getX(), start.getY(),width ,height );you're assuming it is the top left point. I imagine this might contribute to your "blank areas" issue, but I'm not sure.
    Change your Selector class to the code below, and the rectangle will always work (at least it does on my machine --> java 1.6.0+)
    class Selector extends MouseInputAdapter
        ImageSelectionPanel selectionPanel;
        Point start;
        public Selector(ImageSelectionPanel isp)
            selectionPanel = isp;
        public void mousePressed(MouseEvent e)
            start = e.getPoint();
            selectionPanel.setClipFrame(start, start);
        public void mouseReleased(MouseEvent e)
            Point end = e.getPoint();
            end.x = Math.min(Math.max(end.x,0),selectionPanel.image.getWidth());
            end.y = Math.min(Math.max(end.y,0),selectionPanel.image.getHeight());
            selectionPanel.setClipFrame(start, end);
            System.out.println("START="+start);
            System.out.println("END="+end);
            Rectangle clip = selectionPanel.clip;
            if(clip.width > 0 && clip.height > 0)
            MergeImages.GenerateFourImagesDragAndDrop(crop1.fileName,
                                                      clip.x,clip.y,
                                                      clip.width,clip.height );
        public void mouseDragged(MouseEvent e)
            selectionPanel.setClipFrame(start, e.getPoint());
    }You will see that a new problem surfaces. That problem is that generated patterns affect previous ones. I imagine this has to do with your extensive use of static variables. Any swing person will tell you that a static GUI component constitutes as a bad idea in the majority of situations. But I'll let you deal with that.

  • Adjusting a created pattern swatch

    Hello all,
    I've been searching around for a solution to my problem, it seems so basic that i'm suprised i can't find anything on the subject (maybe i use the wrong therm's).
    I have the following question, is it possible to adjust a pattern after it has been created ? So what i have done is made some artwork with vector graphics in a document, dragged it into the swatches pannel to create a pattern swatch of it. So far so good, i can apply the swatch to a rectangle f.e. and it will get filled with my artwork. But now i want to  be able to adjust the fill color of my pattern, i haven't been able to adjust the pattern swatch itself, the only thing i can do now is adjust the original artwork, create another swatch and apply it again to my rectangle.
    Is there a way that i can adjust the pattern instead of having to adjust my original artwork, and create another swatch of it ?
    Any help would be very cool
    Grts!, Samuel

    Samuel,
    You should be able to drag the pattern swatch into the Artboard, when nothing is selected ther, and modify (you may use the Direct Selection Tool to pick spefific parts), and drag it back to form a new pattern swatch or Alt/OptionDrag it back upon the original swatch to replace it.
    You may search for Modifying patterns in the Help file to see updates to the way described.

  • Creating a cartoon from regular image

    Okay, I am trying my hands at vector graphics and there is
    something that I found that I really want to learn to do. I would
    like to know how to take a regular image and make it look like a
    type of cartoon.
    Here are two example of what I am looking to do:
    http://www.flickr.com/photos/jessicafinson/103540135/
    and
    http://www.flickr.com/photos/boytron/13880620/
    As you can see both of the photos have been taken from
    regular images, but they have a cartoon look to them. How do I do
    this? Are there any tutorials that I can look at to see?
    Thanks for the help,
    T.

    TSanchez012 wrote:
    > Okay, I am trying my hands at vector graphics and there
    is something that I
    > found that I really want to learn to do. I would like to
    know how to take a
    > regular image and make it look like a type of cartoon.
    >
    > Here are two example of what I am looking to do:
    >
    http://www.flickr.com/photos/jessicafinson/103540135/
    >
    > and
    >
    >
    http://www.flickr.com/photos/boytron/13880620/
    >
    > As you can see both of the photos have been taken from
    regular images, but
    > they have a cartoon look to them. How do I do this? Are
    there any tutorials
    > that I can look at to see?
    >
    > Thanks for the help,
    > T.
    >
    This might be helpful:
    http://www.communitymx.com/content/article.cfm?cid=72884
    Jim Babbage - .:Community MX:. & .:Adobe Community
    Expert:.
    http://www.communityMX.com/
    CommunityMX - Free Resources:
    http://www.communitymx.com/free.cfm
    .:Adobe Community Expert for Fireworks:.
    Adobe Community Expert
    http://tinyurl.com/2a7dyp
    See my work on Flickr
    http://www.flickr.com/photos/jim_babbage/

  • JS[CS3] Create Pattern/Swatch

    I am new to JS
    in AI. I know pretty well JS in ID but the object is totally different.
    So I am creating a layer, naming it, Creating a box, Importing an EPS as a groupItem.
    NOW the tricky part. The imported EPS is my Stamp so I need to create a pattern from it.
    Then apply that pattern to my box. That is where I loose myself. I don't comprehend the relationship between stwatch, pattern & Patterncolor. But I did understand that a swatch COLOR can be of type PatternColor and there you can access its properties like angle, scale, etc... But a PatternColor is a Pattern itself?!? I also understand I can access my pattern using the swatches because a pattern is actually a swatch color.
    Any pointer on how to create a pattern from my groupItem? Pattern.add method has no argument, right?
    So I can't do
    var myDoc = app.activeDocument;
    var myStamp = myDoc.groupItems.createFromFile(myFile);
    var myPattern = myDoc.patterns.add(myStamp);              <---- Error
    myPattern.name = "XXX";
    var mySwatch = myDoc.swatches.getByName("XXX");
    mySwatch.color.rotation = 45;
    mySwatch.color.scaleFactor= [50, 50];
    var myRCT = myDoc.pathItems.rectangle(myDoc.pageOrigin[1], myDoc.pageOrigin[0], myDoc.width, -myDoc.height);                              
    myRCT.fillColor = mySwatch.color;     <---- DOES not apply it maybe because a pattern?
    Any help is appreciated

    Yes that is what I get as well. There as to be a way to assign, just like the GUI does.
    Compared to InDesign, AI scripting sucks. It is really poorly implemented. Even the help is sketchy at best.
    I'll keep trucking along and post my findings.
    Cheers, Alex.

  • Creating a magazine from Photoshop Images and transferring them to InDesign

    Hello,
    I'm in the process of creating a magazine. I have already started created the pages including their layout in Photoshop. I have CS4 and I want to transfer those images to InDesign and also incorporate Flash to produce a web-base magazine. How do I transfer those Photoshop images (files) into InDesign and also incorporate Flash.
    Attached are some finished pages so that you will have something to show me, in detail, on how this process is done, and/or IF, it can be done.

    Hi, smitty212.
    Hopefully everyone can agree to ignore some of the dialog above.
    Your question is a bit difficult, in large part because it appears that you did a lot of work in a way that could be very difficult to transfer, but you haven't given us full information about what you really have and what you need.
    Generally speaking, editable text in Photoshop is not very flexible. It's not easy to manage large amounts of text there, and depending on how you have used it, it may be nearly impossible to get the text out without retyping it.
    The normal use of InDesign, as you've probably gathered by now, is to place the text in text frames (either by typing or by File > Place-ing it from another application, or maybe cut-and-paste but probably not), and to place graphics in graphics frames (again, with File > Place. Never with cut-and-paste, which causes all manner of problems).
    Ideally, then, you'd have all the images in your layout as seperate files, and the text, too, and you could compose the layout as normal.
    The hard part will be rescuing the text. You may be able to cut and paste it out of Photoshop.
    It is possible that you might be able to save some work by converting pieces of the Photoshop layout to smart objects and placing those into InDesign.
    One thing to consider is how resolution-independent your output is going to be. In Photoshop, everything is a pixel. So if the work was done at a low resolution, it won't support resizing in InDesign. This is especially true of text that has been rasterized (converted to pixels). But if everything was high enough resolution in Photoshop, you may be able to get away with just placing the Photoshop images in InDesign. It won't be easily editable, but maybe that's ok.
    I hope this helps.

  • How can you create a swatch from a jpeg in Illustrator CS4?

    I am trying to create a jpeg image into a swatch in Illustrator CS4. In previous versions you could simply drag the image into the swatches toolbar and it would convert it automatically. Now when I do that nothing happens. When I click on new swatch it creates a colour swatch instead of the actual image itself.

    When you say you would drag the image itself into the Swatch Palette and it would show the image itself? How would then use this swatch? Can you give an example of what you would apply a jpeg to as a swatch? The only palette that I can think of off the top of my head that you can drag a jpeg into and have the icon appear as the jpeg is the Symbols Palette. Is is possible that you were using the Symbols Palette in the past and not the Swatch Palette?

  • Creating a Book from selected images in Aperture browser creates empty book

    I have been a happy user of Aperture 2 for several weeks now but I have been stumped by a problem when I come to layout a book. Help please!
    The problem is that any book I create contains no pictures in the aperture browser - so I can't add anything to my empty books. I have tried everything to get images into my book but nothing works. What is odd is that Projects tab I see that the total number of photos I selected at book creation time is given correctly. I just can't see any in the browser.
    I have also tried to drag and drop pictures into the book pages and the project folder but nothing happens.
    Any help is much appreciated.
    Steve

    Hi Thomas,
    Thanks so much for replying.
    In answer to your question - the bottom bar of the browser does not say anything - and yet the Projects tab lists the book and also the number of images that I selected when I made the New -- Book from the pull down menu option.
    I also tried to add images to the book's browser by drag and drop from another project or folder to the name of the book project in the project list. It doesn't work for me.
    Very odd as I have been happily importing, exporting and publishing web galleries for several weeks now.
    FYI, my Aperture library is about 100 Gb in size with 7,700 photos. I run OS X 10.5.3 on my Intel MacBook Pro 17 inch with 6TB of firewire connected disks.
    Any help or ideas are very much appreciated.

  • Why can't I pull my pattern swatch from the palette to the artboard?

    This is a new problem that I have never had before.  I want to alter the colors of my pattern. Typically, I pull it from the palette to the artboard, change my colors.. re-select the entire patterns repeat and drag and drop it back into the swatches palette. None of my layers are locked and all are visible.  What's the deal?  (iMac CS2)  (I have loaded up other files with patterns in them and it works just fine!)  (I have also quit .AI and reloaded the same file with the same problem.)
    Thanks

    THose phrases are explained in the manual:
    http://help.adobe.com/en_US/illustrator/cs/using/WS714a382cdf7d304e7e07d0100196cbc5f-62c7a .html
    https://helpx.adobe.com/illustrator/using/clipping-masks.html

  • How to create 12bit Prores4444 from an image sequence

    Hi,
    there seems to be a lot of confusion on the web regarding the bit depth of Prores4444. The white paper states that is supports "up to" 12bit for color components (YCrCb or RGB) and "up to" 16 bit for alpha and people seem to disagree whether it always uses 12bit or whether it uses 10bit when no more is needed.
    Having said that, I would like to create a Prores4444 file from a sequence of 16bit (per component) images (I could produce png or tiff or dpx) and for obvious reasons ensure I get the full 12bit of colour and the full 16 bit of alpha.
    So, two questions:
    How do I do that? I have final Cut Studio installed. Does Compressor offer that? Do I have to do something special to achieve this or will it automatically do this right based on the input material?
    How to I check if the result is really 12bit? Is there any tool that will tell me, if the resulting file is really a 12bit file (provided the "up to" in Apple's whitepaper was no accident)?
    Thank you in advance,
    Robert

    The only part of this equation that I can speak to is converting an image sequence to a quicktime move.
    Simplest way to work with an image sequence is to use quicktimeplayer7 to open an image sequence and then save it.  It will save as a quicktime with the same properties as the individual image files.  You will have to define the desired frame rate.  If I remember correctly, quicktime player 7 is an optional install on the snow leopard disk.  Not sure if it's still included with Lion or Mountain Lion. 
    You can change the still image default length to one frame and import all your still images into fcp and then simply drag them to the timeline, but fcp will struggle to play the sequence.  If you need to work this way, you should immediately export as a quicktime.
    Also, be sure and use leading zeros in numbering your image sequence as apple (and fcp) will not sort files properly, unless for example, your files are labelled. 001, 002, 003, etc.  (assuming you have less than 1000 files).

  • Disk Utility to Create a DVD from an image

    I get stymied when I try to us a diskimage as a source to make a DVD. I have a new DVD-R and it always wants to erase the disk, I cant get past that screen after I choose the drive as the destination. It wants to erase the disk but says it cannot erase this disk. There is noting in the help file to shed light on what to do. How do I make a DVD from a disk image ceated with iDVD?

    I'm not sure how you are doing it but it should be done as follows. open Disk Utility and drag the disk image to the left pane in DU just below the volume list. then select the disk image in DU and press the "burn" button in disk utility toolbar.

  • Creating a PDF from an image using Adobe Reader 9.0

    Hi, I've converted a bitmap image to Adobe PDF using Adobe Reader 9.0. I was able to open and read the file but not to modify it. The resulting file ended up being password protected. I do not have a password. I am using Adobe Acrobat X. Can you help?

    I used an application called Bloomberg (feed with investment info) from where I was offered to convert an image into a PDF to save it. The laptop on that station is loaded with Acrobat Reader 9.0.

  • Looking for comprehensive program to create pdf file from gif image

    Hello,
    I'm looking for a program that can transform gif image file into pdf file. It is very importent to keep the same quality of the output document as the original image.
    I've seen Bridge CS5 in action and was very much disapointed, because the original gif image had 2 colors: black and white, took 60k Byte A4 paper size. But the output pdf file became somehow to 700k Byte size. When our proffi tried to lower the ppi or quality bar there was direct impact on the image quality.
    Long time ago Photoshop was able to export images as pdf files and one of the options of the pdf file was to keep the original image as gif, not as jpeg. Because jpeg is very costy format for black-white images and no-one wants to waste memory in vain, so I do not like to save pdf files of 1MB size for an image that takes 100k in gif.
    I do understand that nowdays using Photoshop to save pdf files is not the option anymore, isn't it ?
    What program can you suggest me to use ? I still prefer to use Adobe products, as long as I can, through I'm starting to get scared of sharp decline in quality.
    Thank you in advance.
    sincerely,
    Al

    No, I didn't. The last time I saw it, it was looking just as a regular Reader with a little more options and with an addon to MS-Office, to allow to save MS documents to pdf from inside MS-Office user interface products, and frankly, I do not highly admire there products at all, so I do not have MS-Office installed. But it was also long time ago. If the situation did changed since than,  I will try it.
    Thank you very much.
    I've just tried the Acrobat. It worked great ! Thank you. Just not all the images have options how to save them in pdf file, but that's ok for now

Maybe you are looking for

  • HDMI Sound Problem - Qosmio X70-A

    Hi All ...  I have problem with HDMI sound on tv , when i connect the HDMI the sound comes from my Leptop not from the TV ive been days looking for solution downloaded from toshiba drivers and didnt solve , and download from Intel and didnt work also

  • Multiple instances of a table & join supported in OBIEE SQLQuery report

    Hello All, I am creating a report in BIP based on the RPD created in OBIEE. I have to use multiple instances of same table in this case. But when I do that, I am getting "'The query contains a self join/This is a non-supported operation" error. Have

  • Bug in JRE 1.4.0

    Hello, My applet doesn't display properly with Sun's JRE 1.4.0. It doesn't properly repaint the applet area, so my applet appears frozen. The applet: http://www.mandelmania.net/mandelmania.html Is there a fix for this, or a workaround? For now I've u

  • List/menu

    I am trying to update 3 field when I pick field from List/menu please help how to do this code below <select name="LookupLeadNo" id="LookupLeadNo"> <?php do { ?> <option value="<?php echo $row_fmLeads['LeadNo']?>"<?php if (!(strcmp($row_fmLeads['Lead

  • Monitoring of new modules

    Hi How can we monitor performance of Expressway, MSE chassis with TP Server and Conductor? Also to send alerts for SNMP traps, is it supported by Prime Collaboration Unified Communication Suite?