RE: Image files (Save, Rename)

Hi programmers,
I need some help on coding.
I have a subfolder that contain all the small tile Images and I have the program to stitch the images into a complete image and I'm able to save only one complete Image one at a time, I now need to open only the root folder, rename the complete Images and save the image in a specific format.
But I need to change the file name for example for my situation one of my file format is
060313_0114PM_XY_MULTI-TILE_X=011_Y=011_RUN006109_SAMPLE_D_205 
and there is a pattern with the format where I have to sort all the files and refine my search with those files with SAMPLE_A_ , SAMPLE_B_, SAMPLE_C_ and SAMPLE_D_ and put it into an array of strings... and rename the file and save the file in this format. eg. SAMPLE_A_205.tif, SAMPLE_B_207.tif ...
Do anyone got any clue or tips to help me?
Thanks,
Alan

But I need to refine and select only those files with "Sample_A_", "Sample_B_", "Sample_C_" and "Sample_D_"
I tried match pattern but it don't work from the output of list folder.
I done some codes though, mind if you take a look at them?
Attachments:
User Interface (30052013).vi ‏48 KB
Image Stitching.vi ‏55 KB
Image Saving.vi ‏17 KB

Similar Messages

  • Is there a way to save an image file as a jpeg and add -web or -print to the file name?

    I am trying to find a way to save my image file as a jpeg and add -web or -print to the existing file name.  This way I can easily see which files are lower resolution for web posting or high resolution for printing.

    Jason,
    I helped somebody do a very similar thing about a week ago.
    The trick is to use the Batch command's ability to construct a file name.
    Tell the batch to append, e.g. "-x" without quotes, to the name of each saved file.
    The batch runs an Action which does a save as JPEG, resize image, add logo, save as JPEG, then close document.
    The output is "<document name>-x.jpg" and "<document name>-x-x.jpeg".
    Then use Windows Explorer to rename "*-x-x.jpg" to "*-print.jpg".
    Then rename "*-x.jpg" to "*-web.jpg".
    See http://forums.adobe.com/thread/1038992?start=32
    The name construction that I used there was just an "x" appended to the document name. Use whatever you like. Also juliew subsequently referred to the method as a "double-batch" run, although it is not. One run of the batch will output two JPEGs for each input document.
    I hope the disagreements in that thread don't cause too much disruption.
    If you want, the Batch command itself can be recorded in another Action which would store the parameters of the batch, then you could run that Action anytime without having to set up the details of the batch each time. It would always output to one specific folder, though.

  • Batch Renaming Image Files from a list of names

    I would like to use the batch rename function in Bridge CS5 to quickly rename newly uploaded image files of our products.  I would like to rename the image to it's corresponding product number.  The issue is that the product numbers aren't in exact numerical order (ie.  the first pic is of product ES2004 and the next one is for ES2012).  The product numbers can sometimes end with a letter or a number.  The pictures are taken in order of the product numbers on an excel sheet.  What's the easiest way to have bridge name the image file to its corresponding part number? 

    Here is an example script that will do the re-naming also place the original filename into the metadata.
    CSV format is fileName,Product IE:
    p1020337.jpg,E179562
    p1020338.jpg,Z556301
    Copy and paste the script into ExtendScript Toolkit (This gets installed with Photoshop)
    Open Bridge
    Edit > Preferences > Startup Scripts
    Click "Reveal My Startup Script"
    Save the script into this folder.
    Close and restart Bridge and accept the new script.
    To use, navigate to the folder with the documents to rename, "Right mouse click Menu" select "Rename to Product" and select your csv file.
    #target bridge 
    if( BridgeTalk.appName == "bridge" ) { 
    fileNameToProduct = MenuElement.create("command", "Rename to Product", "at the end of Thumbnail");
    fileNameToProduct.onSelect = function () {
       renameToProduct();
    function renameToProduct(){
    var Path =app.document.presentationPath;
    var descFile = File.openDialog("Open Product File","CSV File(*.csv):*.csv;");
    if(descFile == null) return;
    descFile.open('r');
    var datFile=[];
    while(!descFile.eof){
    var line = descFile.readln();
    if(line.length > 5) datFile.push(line);
    descFile.close();
    for(var t in datFile){
    var str=datFile[t];
    str= str.split(',');
    var fileName = File(Path+"/"+ str.shift());
    var product = str.shift();
    if(!fileName.exists) continue;
    var ext = fileName.toString().toLowerCase().match(/[^\.]+$/);
    var thumb  = new Thumbnail(fileName);
    var md = thumb.synchronousMetadata;
    md.namespace = "http://ns.adobe.com/xap/1.0/mm/";
    md.PreservedFileName = thumb.name;
    $.sleep(100); //give it time to update the metadata
    var newName = product + "." +ext;
    fileName.rename(newName);
    alert("All done");

  • Save renames the file

    In PS CS6, when I save an image, it saves the image in the correct folder but renames the image PT-guipano(original file name).jpg.  For example: I open a file from LR4.1 by selecting the image and choosing (edit in PS CS6), then choose (edit the original).  This opens the file in PS, I make some adjustments and hit (command S) on the keyboard.  The image appears in LR in the original folder with a new name. 
    BTW I asked for help on a PT Gui forum and they said it was not a PT Gui related issue.
    Any suggestions would be appreciated.

    This is what I thought as well.  I asked about it on a PT Gui forum and they said they have no idea and that there is nothing in PT Gui that would cause this to happen.
    My workflow involving PT Gui is to open multiple files from LR or PS or PT Gui into PT Gui.  Create a pano and save it to PS with layers.  Edit the pano in PS and bring it into LR.
    My guess is that when I saved a pano in PS, something ocurred to influence PS to insert (PT-GUI pano) into the file name when I save a file in PS.

  • TWO CRITICAL BUGS: 1) File, "Save Page As" and 2) right-click the picture and select "Save Image As", both do not work at all in Firefox 27, 28, and 29!

    Note: capitals are used only to highlight important words.
    PLEASE, TAKE THESE COMMENTS ON TWO CRITICAL BUGS VERY SERIOUSLY BECAUSE THE BUGS DESCRIBED BELOW ARE SO CRITICAL THAT I CANNOT USE THE LATEST VERSION OF FIREFOX UNLESS THEY DO NOT APPEAR IN THE LATEST VERSION AND THEREFORE I AM FORCED TO REVERT BACK TO FIREFOX 26.
    I have Windows 7 64-bit and Firefox 26. I could not install Firefox 27, 28, and 29 due to the persistent presence of the two critical bugs described below. I have 8 GB of RAM and an Intel quad-core processor and a lot of hard disk space available.
    I installed Firefox 27 and then Firefox 28 a while back and these two bugs described below were still present and now I have just checked again with Firefox 29 by installing it and yet again, these two bugs described below are present!! UNBELIEVABLE THAT THESE TWO CRITICAL BUGS ARE STILL PRESENT IN FIREFOX 29 WHEN I CLEARLY INFORMED YOU ABOUT THEM IN THE HELP, SUBMIT LINK OF FIREFOX!!
    I am forced to revert to Firefox 26!
    First, I use Windows 7 64-bit and I always use Firefox with at least 120 tabs opened. BUT I have 8 GB of RAM, an Intel core i7 quad-core processor and more than 1 TB of hard disk space. Consequently, I do not understand why I would have these two critical bugs.
    With Firefox 26, I also have at least 120 tabs opened when I start Firefox and I do not have the two critical bugs described below, therefore I do not believe that the number of tabs is the reason of the two critical bugs that are present in Firefox 27, 28, and 29.
    ---FIRST CRITICAL BUG:
    When I open ANY web page and do File, "Save Page As", the window that is supposed to open to locate the folder where I want to save this web page does NOT open at all, even if I wait a long time to see if it opens.
    Same problem happened with Firefox 27, 28, and now 29!! When I reverted back to Firefox 26, this problem did NOT happen anymore!
    ---SECOND CRITICAL BUG:
    When I use Google Images, for instance entering model in the search field of Google Images and then pressing enter.
    Then I select any picture, open to a new tab this selected picture, then open a new tab by selecting the option View for this picture. Then right-click the picture and select "Save Image As".
    Again, the window that is supposed to open to locate the folder where I want to save this picture does NOT open at all, even if I wait a long time to see if it opens.
    Same problem happened with Firefox 27, 28, and now 29!! When I reverted back to Firefox 26, this problem did NOT happen anymore!
    ---THESE TWO CRITICAL BUGS DO NOT APPEAR WHEN I USE INTERNET EXPLORER 11.
    I have no idea if you will be able to reproduce these two critical BUGS but I can assure you that they are not present when I use Firefox 26 and they are present when I use Firefox 27, 28, and 29. More, be aware that I have at least 100 tabs opened but I also have this same number of tabs opened in Firefox 26 and yet I do not experience these two critical bugs when I have Firefox 26!
    Once again, these two bugs touch at two vital, critical very basic functions of Firefox and therefore I will NOT be able to use any version above 26 if these two bugs are still present, as they are present in Firefox 27, 28, and now 29!!!
    Please, make it a priority to solve these two critical bugs. Thanks.
    I did read a post related to the same issues “Firefox stops responding when trying to "save page" or "save image" | Firefox Support Forum | Mozilla Support” at https://support.mozilla.org/en-US/questions/991630?esab=a&as=aaq
    I am still reading it again to try to figure out exactly what the person did to make his problems be solved, as the post is not clear at all on what solved the problems!
    In any case, all the suggestions proposed in this post do not work and I surely cannot do a system restore when it is obvious that the two bugs do not appear in Internet Explorer.

    First, I sent an email to the author of PhotoME to inform him of the serious issues his addon caused with Firefox latest versions.
    Now, for those of you who do not have the PhotoME addon and yet experience the same problem that I had and that I described above, I suggest the following strategy.
    As PhotoME did cause these problems with Firefox latest versions, I am pretty covinved other addons probably might cause these problems too. Therefore, adopt the following method.
    Test one addon at a time to see if this particular addon is behind your Firefox issues like the ones I had.
    So, disable one addon only at a time. Then close your Firefox and restart it from scratch and see if you still have your Firefox problems. You must restart the Firefox browser from scratch. If you still have these Firefox problems, re-enable the disabled addon, restart your Firefox (again!) and repeat the same method for every single addon that you have.
    Try to be selective by choosing first addons that are more likely to cause your Firefox problems such as not very well-known or not very popular addons (like it was the case for the PhotoME addon).
    If this method works or if it does not work, report it on this web page so that others can be helped with your comments.
    I hope this method will help you because I was really upset that I had these Firefox problems and I first thought it was the fault of Firefox, only to discover later that this PhotoME addon was the culprit and had caused me such upset.

  • How to save uploaded image file to Apache Web Server from Tomcat

    Hi guys,
    Perhaps this is not an appropriate topic to ask under this forum but I really don't know where should I post my question. Hope you understand.
    Ok, I need to know if my web application is running in Tomcat5 and user uploading some image file where I need to save these image files to the other server, which is running Apache Web Server. Should I ftp to there or other better method ?
    Anyone got a better idea on doing this kind of process pls advice. Many Thanks !
    regards,
    Mark

    if your Apache server is running in the same computer and if your servlet have write access to the folder in apache under which you want to save the file you can just write the file there but you will have to address concurrency issues.
    Otherwise you will have to do ftp but since apache does not have abuilt in frp server you will need a seperate FTP server for this

  • Moving and renaming image files

    I want to move & rename image files to folders on the hard drive by dragging and dropping them into my application. I read about the problem with renameTo() method with windows. Is this possible to do in java? I heard about a method in which you read,write and delete the old file? How do I go about making this happen?

    Well, what happens if you create the folder C:/Test/testfile1.txt ?
    Or alternatively remove the part that says "testfile1.txt" from the directory path in your program.
    Or alternatively call dir.mkdirs() before trying to rename.
    What I am getting at is that when you create a file with the constructornew File(dir,newdest.getName())the parameter dir is treated as a directory no matter what its name is. If its name is "C:/Test/testfile1.txt," the name of the new file will be "C:/Test/testfile1.txt/name_of_newdest"where name_of_newdest is the name of the "newdest" file. This might not be what you wanted

  • How do i disable the open/save image dialog box in firefox? I want to directly save the image file to the drive.

    How do i disable the open/save image dialog box in firefox? I want to directly save the image file to the drive without clicking on save option everytime when saving an image. I'm using firefox ver 35.0.1 for windows 7.

    Click on the Firefox menu. Then click "Options". Go to "Applications" tab. Search for jpg and png file type. You will find they have "Always ask" action attribute. Change it to "Save file".
    Hope it will work fine for you.

  • HP Photo Creations - Save as image file

    I've just spent the best part of 3 hours creating two photo collages in this application and cannot for the life of me see how I save the project as an image file.
    The only option I have found is to save it as a 'project'.
    Please tell me I haven't wasted my time?
    I even shared it somewhere, rocket something or other.  Can't do anything useful with it from there either.  So I'd like to know how I can delete the published project too please.
    Thanks in advance.

    Hi RWengel.
    You wrote, "It would seem that since you can only share via the program that that this is photo software second  to marketing software."
    The Share function in HP Photo Creations offers sharing via Facebook, Twitter, Pinterest, email, web link, and embedding. In addition, people with whom you share the project can print it in full resolution. How else would you like to share your projects? 
    Incidentally, here's how I used Microsoft's Snipping Tool to capture an image of the fullscreen preview on Windows 7:
    Launch Snipping Tool. Choose Rectangular Snip mode.
    Click Full to set HP Photo Creations project to fullscreen mode.
    Press Alt-Tab to call up Snipping Tool.
    Press Alt-N to create a new snip.
    Click and drag around the area you want on the HP Photo Creations window.
    As mentioned above, the sharing option creates a link to a printable (and re-sharable) version, so it's a better-looking approach. Again, let us know what you're hoping to do with your images and we may be able to suggest a way to do it.
    Thanks for trying HP Photo Creations,
    RocketLife
    RocketLife, developer of HP Photo Creations
    » Visit the HP Photo Creations Facebook page — news, tips, and inspiration
    » See the HP Photo Creations video tours — cool tips in under 2 minutes
    » Contact Customer Support — get answers from the experts

  • Renaming image files

    I'm using iWeb 1.1.2 If I click on the metrics tab under "Inspector", it will list the name of any image file I select. Is there any way to change the name of an image file without removing it from iWeb, changing it, then re-inserting it into iWeb?
    Some of my image file names consist of several words and a date. I need to shorten names and eliminate spaces between words or numerals.
    Help would be appreciated.
    LaughingBear

    Hello Old Toad,
    The images are interspersed with text on regular webpages, not in albums or anything fancy.
    Yes, I tried changing names in the Domain files, but that just confused the index.html file, ruining the webpage.
    The URL is bear-viewing-in-alaska.info.
    That site is hosted by Yahoo. My iWeb site was created through iMac and then transferred automatically to Mobile Me.
    Since search engines have great difficulty finding that content, I have been trying to transfer my pages from Mobile Me to Yahoo. But Yahoo cannot read file names that contain spaces or "&" signs, which some of my photos have. So I have been trying to rename the image files.
    Put differently, I'm trying to get all of my pages into a single website (rather than 2 inter-linked websites), if not with Yahoo than with some other host that is search-engine-friendly. I initially tried shifting to RAGE, but they were just starting up as a host and did not seem to have their act together yet.
    Given my desire to switch hosts, I have not paid Mobile Me for another year; so the webpages I created on iWeb cannot be viewed there. However, I've managed to transfer a few files to the Yahoo website. You will find them by clicking on "Senior Staff" near the upper right of the homepage, then clicking on "Author." That will lead to a series of images of artwork I've created.
    Look forward to your insights.
    Laughing Bear

  • Renaming image files in aperture?

    how do I rename my image files. I need to do this in order for my photos to be accepted in 'Hugin'. at the moment it says error, this file contains invalid characters, hugin can't use files with these filenames, please rename files. what do I do? 

    When you export the version from Aperture you are free to name the exported version anything you wish. Use a format that is acceptable to the site you are sending  the files to.
    Or else just rename the already exported images using the finder.

  • I save as tiff, but ends up as micrsoft office document imaging file

    Can anyone help me out there? I save an image as a tiff in CS2, but when I view the image details in the folder it reads as a
    microsoft office document imaging file..
    I have been saving as tiffs for years, but only recently has this started happening.
    Thanks

    lisapowell wrote:
    Can anyone help me out there? I save an image as a tiff in CS2, but when I view the image details in the folder it reads as a
    microsoft office document imaging file..
    What is the actual extension of the file name in Windows Explorer?

  • Is it possible to save a picture/image file that is within an iOS app?

    Is it possible to save a picture/image file that is within an app?
    The image in question cannot be shrunk, so using the iPhone built-in Screenshot function (by pressing both "Home" & "On/OffSleep/Wake" buttons simultaneously) only produces part of the image.
    Thanks.

    Generally in all Apple iOS apps, you can hold down on the image and the save image dialogue will pop up. Many third party developers adopt this method, but some also have other weird ways of doing it through menus. What appa re you trying to do this with?

  • Save image file in server machine from client

    hai
    I am working in swing based applications on linux environment.
    I can able to save the image file from java appln to local directories.
    My doubt is
    how to save that image file in another machine in the same network or in the server machine through java application insead of saving in the local machine.
    if anyone can help me to findout the solution?
    advance thanks,
    Samy.

    The file can be read in the weblayer if it is sent as a mutlipart request. So once u have it i the Webserver u can always send it to the app server by posting it in a location which the app server can read using URL api

  • How do i save my drawing as an image file?

    hiee
    I have made a drawing panel on an Internal frame.
    I can draw basic 2D shapes on it.
    Now , i wanted to save this as an image file (ie.gif or jpeg).
    How do i do that??

    * SaveAsGif_Demo.java
    * Created on 13 mars 2005, 11:26
    import java.awt.*;
    import java.awt.image.*;
    import java.io.*;
    import java.util.Dictionary;
    import java.util.Enumeration;
    import java.util.Hashtable;
    import java.util.NoSuchElementException;
    import javax.swing.*;
    * @author  Andr� Uhres
    public class SaveAsGif_Demo extends javax.swing.JFrame {
        /** Creates new form SaveAsGif_Demo */
        public SaveAsGif_Demo() {
            initComponents();
            myPanel = new MyPanel();
            getContentPane().add(myPanel, BorderLayout.CENTER);
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        private void initComponents() {                         
            jToolBar1 = new javax.swing.JToolBar();
            jButton1 = new javax.swing.JButton();
            jLabel1 = new javax.swing.JLabel();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            setTitle("Save as .gif Demo");
            jToolBar1.setFloatable(false);
            jButton1.setText("Save");
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton1ActionPerformed(evt);
            jToolBar1.add(jButton1);
            jToolBar1.add(jLabel1);
            getContentPane().add(jToolBar1, java.awt.BorderLayout.NORTH);
            java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
            setBounds((screenSize.width-400)/2, (screenSize.height-300)/2, 400, 300);
        private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
            File file = new File("c:\\test.gif");
            if(SaveAsPic.saveGif(file, myPanel.captureJPanel(myPanel))){
                jLabel1.setText("The diagram was saved as " + file.getAbsolutePath());
                return;
            jLabel1.setText("Error:failed to save as gif");
         * @param args the command line arguments
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new SaveAsGif_Demo().setVisible(true);
        // Variables declaration - do not modify                    
        private javax.swing.JButton jButton1;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JToolBar jToolBar1;
        // End of variables declaration                  
        private MyPanel myPanel;
    class MyPanel extends JPanel {
        MyPanel(){
            super();
        public void paint(Graphics g){
            g.drawRect(10, 10, 100,100);
        Image i ;
        public Image captureJPanel( JPanel jp ) {
            i = this.createImage( jp.getSize().height, jp.getSize().width );
            Graphics g = i.getGraphics();
            jp.paint( g );
            return i;
    class SaveAsPic {
        public static boolean saveGif(File file, Image image) {
            boolean flag = true;
            try {
                FileOutputStream fileoutputstream = new FileOutputStream(file);
                GifEncoder gifencoder = new GifEncoder(image, fileoutputstream);
                gifencoder.encode();
                fileoutputstream.close();
            catch(IOException ioexception) {
                System.out.println("Error encoding Gif-file: " + ioexception.getMessage());
                flag = false;
            return flag;
        SaveAsPic() {
    class IntHashtableEnumerator
        implements Enumeration {
        IntHashtableEnumerator(IntHashtableEntry ainthashtableentry[], boolean flag) {
            table = ainthashtableentry;
            keys = flag;
            index = ainthashtableentry.length;
        public boolean hasMoreElements() {
            if(entry != null)
                return true;
            while(index-- > 0)
                if((entry = table[index]) != null)
                    return true;
            return false;
        public Object nextElement() {
            if(entry == null)
                while(index-- > 0 && (entry = table[index]) == null) ;
            if(entry != null) {
                IntHashtableEntry inthashtableentry = entry;
                entry = inthashtableentry.next;
                if(keys)
                    return new Integer(inthashtableentry.key);
                else
                    return inthashtableentry.value;
            } else {
                throw new NoSuchElementException("IntHashtableEnumerator");
        boolean keys;
        int index;
        IntHashtableEntry table[];
        IntHashtableEntry entry;
    class IntHashtableEntry {
        protected Object clone() {
            IntHashtableEntry inthashtableentry = new IntHashtableEntry();
            inthashtableentry.hash = hash;
            inthashtableentry.key = key;
            inthashtableentry.value = value;
            inthashtableentry.next = next == null ? null : (IntHashtableEntry)next.clone();
            return inthashtableentry;
        IntHashtableEntry() {
        int hash;
        int key;
        Object value;
        IntHashtableEntry next;
    class IntHashtable extends Dictionary
        implements Cloneable {
        public IntHashtable(int i, float f) {
            if(i <= 0 || (double)f <= 0.0D) {
                throw new IllegalArgumentException();
            } else {
                loadFactor = f;
                table = new IntHashtableEntry;
    threshold = (int)((float)i * f);
    return;
    public IntHashtable(int i) {
    this(i, 0.75F);
    public IntHashtable() {
    this(101, 0.75F);
    public int size() {
    return count;
    public boolean isEmpty() {
    return count == 0;
    public synchronized Enumeration keys() {
    return new IntHashtableEnumerator(table, true);
    public synchronized Enumeration elements() {
    return new IntHashtableEnumerator(table, false);
    public synchronized boolean contains(Object obj) {
    if(obj == null)
    throw new NullPointerException();
    IntHashtableEntry ainthashtableentry[] = table;
    for(int i = ainthashtableentry.length; i-- > 0;) {
    for(IntHashtableEntry inthashtableentry = ainthashtableentry[i]; inthashtableentry != null; inthashtableentry = inthashtableentry.next)
    if(inthashtableentry.value.equals(obj))
    return true;
    return false;
    public synchronized boolean containsKey(int i) {
    IntHashtableEntry ainthashtableentry[] = table;
    int j = i;
    int k = (j & 0x7fffffff) % ainthashtableentry.length;
    for(IntHashtableEntry inthashtableentry = ainthashtableentry[k]; inthashtableentry != null; inthashtableentry = inthashtableentry.next)
    if(inthashtableentry.hash == j && inthashtableentry.key == i)
    return true;
    return false;
    public synchronized Object get(int i) {
    IntHashtableEntry ainthashtableentry[] = table;
    int j = i;
    int k = (j & 0x7fffffff) % ainthashtableentry.length;
    for(IntHashtableEntry inthashtableentry = ainthashtableentry[k]; inthashtableentry != null; inthashtableentry = inthashtableentry.next)
    if(inthashtableentry.hash == j && inthashtableentry.key == i)
    return inthashtableentry.value;
    return null;
    public Object get(Object obj) {
    if(!(obj instanceof Integer)) {
    throw new InternalError("key is not an Integer");
    } else {
    Integer integer = (Integer)obj;
    int i = integer.intValue();
    return get(i);
    protected void rehash() {
    int i = table.length;
    IntHashtableEntry ainthashtableentry[] = table;
    int j = i * 2 + 1;
    IntHashtableEntry ainthashtableentry1[] = new IntHashtableEntry[j];
    threshold = (int)((float)j * loadFactor);
    table = ainthashtableentry1;
    for(int k = i; k-- > 0;) {
    for(IntHashtableEntry inthashtableentry = ainthashtableentry[k]; inthashtableentry != null;) {
    IntHashtableEntry inthashtableentry1 = inthashtableentry;
    inthashtableentry = inthashtableentry.next;
    int l = (inthashtableentry1.hash & 0x7fffffff) % j;
    inthashtableentry1.next = ainthashtableentry1[l];
    ainthashtableentry1[l] = inthashtableentry1;
    public synchronized Object put(int i, Object obj) {
    if(obj == null)
    throw new NullPointerException();
    IntHashtableEntry ainthashtableentry[] = table;
    int j = i;
    int k = (j & 0x7fffffff) % ainthashtableentry.length;
    for(IntHashtableEntry inthashtableentry = ainthashtableentry[k]; inthashtableentry != null; inthashtableentry = inthashtableentry.next)
    if(inthashtableentry.hash == j && inthashtableentry.key == i) {
    Object obj1 = inthashtableentry.value;
    inthashtableentry.value = obj;
    return obj1;
    if(count >= threshold) {
    rehash();
    return put(i, obj);
    } else {
    IntHashtableEntry inthashtableentry1 = new IntHashtableEntry();
    inthashtableentry1.hash = j;
    inthashtableentry1.key = i;
    inthashtableentry1.value = obj;
    inthashtableentry1.next = ainthashtableentry[k];
    ainthashtableentry[k] = inthashtableentry1;
    count++;
    return null;
    public Object put(Object obj, Object obj1) {
    if(!(obj instanceof Integer)) {
    throw new InternalError("key is not an Integer");
    } else {
    Integer integer = (Integer)obj;
    int i = integer.intValue();
    return put(i, obj1);
    public synchronized Object remove(int i) {
    IntHashtableEntry ainthashtableentry[] = table;
    int j = i;
    int k = (j & 0x7fffffff) % ainthashtableentry.length;
    IntHashtableEntry inthashtableentry = ainthashtableentry[k];
    IntHashtableEntry inthashtableentry1 = null;
    for(; inthashtableentry != null; inthashtableentry = inthashtableentry.next) {
    if(inthashtableentry.hash == j && inthashtableentry.key == i) {
    if(inthashtableentry1 != null)
    inthashtableentry1.next = inthashtableentry.next;
    else
    ainthashtableentry[k] = inthashtableentry.next;
    count--;
    return inthashtableentry.value;
    inthashtableentry1 = inthashtableentry;
    return null;
    public Object remove(Object obj) {
    if(!(obj instanceof Integer)) {
    throw new InternalError("key is not an Integer");
    } else {
    Integer integer = (Integer)obj;
    int i = integer.intValue();
    return remove(i);
    public synchronized void clear() {
    IntHashtableEntry ainthashtableentry[] = table;
    for(int i = ainthashtableentry.length; --i >= 0;)
    ainthashtableentry[i] = null;
    count = 0;
    public synchronized Object clone() {
    try {
    IntHashtable inthashtable = (IntHashtable)super.clone();
    inthashtable.table = new IntHashtableEntry[table.length];
    for(int i = table.length; i-- > 0;)
    inthashtable.table[i] = table[i] == null ? null : (IntHashtableEntry)table[i].clone();
    return inthashtable;
    catch(CloneNotSupportedException _ex) {
    throw new InternalError();
    public synchronized String toString() {
    int i = size() - 1;
    StringBuffer stringbuffer = new StringBuffer();
    Enumeration enumeration = keys();
    Enumeration enumeration1 = elements();
    stringbuffer.append("{");
    for(int j = 0; j <= i; j++) {
    String s = enumeration.nextElement().toString();
    String s1 = enumeration1.nextElement().toString();
    stringbuffer.append(s + "=" + s1);
    if(j < i)
    stringbuffer.append(", ");
    stringbuffer.append("}");
    return stringbuffer.toString();
    private IntHashtableEntry table[];
    private int count;
    private int threshold;
    private float loadFactor;
    abstract class ImageEncoder
    implements ImageConsumer {
    public ImageEncoder(Image image, OutputStream outputstream) throws IOException {
    this(image.getSource(), outputstream);
    public ImageEncoder(ImageProducer imageproducer, OutputStream outputstream) throws IOException {
    width = -1;
    height = -1;
    started = false;
    accumulate = false;
    producer = imageproducer;
    out = outputstream;
    abstract void encodeStart(int i, int j) throws IOException;
    abstract void encodePixels(int i, int j, int k, int l, int ai[], int i1, int j1) throws IOException;
    abstract void encodeDone() throws IOException;
    public synchronized void encode() throws IOException {
    encoding = true;
    iox = null;
    producer.startProduction(this);
    while(encoding)
    try {
    wait();
    catch(InterruptedException _ex) { }
    if(iox != null)
    throw iox;
    else
    return;
    private void encodePixelsWrapper(int i, int j, int k, int l, int ai[], int i1, int j1) throws IOException {
    if(!started) {
    started = true;
    encodeStart(width, height);
    if((hintflags & 2) == 0) {
    accumulate = true;
    accumulator = new int[width * height];
    if(accumulate) {
    for(int k1 = 0; k1 < l; k1++)
    System.arraycopy(ai, k1 * j1 + i1, accumulator, (j + k1) * width + i, k);
    return;
    } else {
    encodePixels(i, j, k, l, ai, i1, j1);
    return;
    private void encodeFinish() throws IOException {
    if(accumulate) {
    encodePixels(0, 0, width, height, accumulator, 0, width);
    accumulator = null;
    accumulate = false;
    private synchronized void stop() {
    encoding = false;
    notifyAll();
    public void setDimensions(int i, int j) {
    width = i;
    height = j;
    public void setProperties(Hashtable hashtable) {
    props = hashtable;
    public void setColorModel(ColorModel colormodel) {
    public void setHints(int i) {
    hintflags = i;
    public void setPixels(int i, int j, int k, int l, ColorModel colormodel, byte abyte0[], int i1,
    int j1) {
    int ai[] = new int[k];
    for(int k1 = 0; k1 < l; k1++) {
    int l1 = i1 + k1 * j1;
    for(int i2 = 0; i2 < k; i2++)
    ai[i2] = colormodel.getRGB(abyte0[l1 + i2] & 0xff);
    try {
    encodePixelsWrapper(i, j + k1, k, 1, ai, 0, k);
    catch(IOException ioexception) {
    iox = ioexception;
    stop();
    return;
    public void setPixels(int i, int j, int k, int l, ColorModel colormodel, int ai[], int i1,
    int j1) {
    if(colormodel == rgbModel) {
    try {
    encodePixelsWrapper(i, j, k, l, ai, i1, j1);
    return;
    catch(IOException ioexception) {
    iox = ioexception;
    stop();
    return;
    int ai1[] = new int[k];
    for(int k1 = 0; k1 < l; k1++) {
    int l1 = i1 + k1 * j1;
    for(int i2 = 0; i2 < k; i2++)
    ai1[i2] = colormodel.getRGB(ai[l1 + i2]);
    try {
    encodePixelsWrapper(i, j + k1, k, 1, ai1, 0, k);
    catch(IOException ioexception1) {
    iox = ioexception1;
    stop();
    return;
    public void imageComplete(int i) {
    producer.removeConsumer(this);
    if(i == 4)
    iox = new IOException("image aborted");
    else
    try {
    encodeFinish();
    encodeDone();
    catch(IOException ioexception) {
    iox = ioexception;
    stop();
    protected OutputStream out;
    private ImageProducer producer;
    private int width;
    private int height;
    private int hintflags;
    private boolean started;
    private boolean encoding;
    private IOException iox;
    private static final ColorModel rgbModel = ColorModel.getRGBdefault();
    private Hashtable props;
    private boolean accumulate;
    private int accumulator[];
    class GifEncoderHashitem {
    public GifEncoderHashitem(int i, int j, int k, boolean flag) {
    rgb = i;
    count = j;
    index = k;
    isTransparent = flag;
    public int rgb;
    public int count;
    public int index;
    public boolean isTransparent;
    class GifEncoder extends ImageEncoder {
    public GifEncoder(Image image, OutputStream outputstream) throws IOException {
    super(image, outputstream);
    interlace = false;
    maxbits = 12;
    maxmaxcode = 4096;
    htab = new int[5003];
    codetab = new int[5003];
    hsize = 5003;
    clear_flg = false;
    accum = new byte[256];
    public GifEncoder(Image image, OutputStream outputstream, boolean flag) throws IOException {
    super(image, outputstream);
    interlace = false;
    maxbits = 12;
    maxmaxcode = 4096;
    htab = new int[5003];
    codetab = new int[5003];
    hsize = 5003;
    clear_flg = false;
    accum = new byte[256];
    interlace = flag;
    public GifEncoder(ImageProducer imageproducer, OutputStream outputstream) throws IOException {
    super(imageproducer, outputstream);
    interlace = false;
    maxbits = 12;
    maxmaxcode = 4096;
    htab = new int[5003];
    codetab = new int[5003];
    hsize = 5003;
    clear_flg = false;
    accum = new byte[256];
    public GifEncoder(ImageProducer imageproducer, OutputStream outputstream, boolean flag) throws IOException {
    super(imageproducer, outputstream);
    interlace = false;
    maxbits = 12;
    maxmaxcode = 4096;
    htab = new int[5003];
    codetab = new int[5003];
    hsize = 5003;
    clear_flg = false;
    accum = new byte[256];
    interlace = flag;
    void encodeStart(int i, int j) throws IOException {
    width = i;
    height = j;
    rgbPixels = new int[j][i];
    void encodePixels(int i, int j, int k, int l, int ai[], int i1, int j1) throws IOException {
    for(int k1 = 0; k1 < l; k1++)
    System.arraycopy(ai, k1 * j1 + i1, rgbPixels[j + k1], i, k);
    void encodeDone() throws IOException {
    int i = -1;
    int j = -1;
    colorHash = new IntHashtable();
    int k = 0;
    for(int l = 0; l < height; l++) {
    for(int i1 = 0; i1 < width; i1++) {
    int j1 = rgbPixels[l][i1];
    boolean flag = j1 >>> 24 < 128;
    if(flag)
    if(i < 0) {
    i = k;
    j = j1;
    } else
    if(j1 != j)
    rgbPixels[l][i1] = j1 = j;
    GifEncoderHashitem gifencoderhashitem = (GifEncoderHashitem)colorHash.get(j1);
    if(gifencoderhashitem == null) {
    if(k >= 256)
    throw new IOException("too many colors for a GIF");
    gifencoderhashitem = new GifEncoderHashitem(j1, 1, k, flag);
    k++;
    colorHash.put(j1, gifencoderhashitem);
    } else {
    gifencoderhashitem.count++;
    byte byte0;
    if(k <= 2)
    byte0 = 1;
    else
    if(k <= 4)
    byte0 = 2;
    else
    if(k <= 16)
    byte0 = 4;
    else
    byte0 = 8;
    int k1 = 1 << byte0;
    byte abyte0[] = new byte[k1];
    byte abyte1[] = new byte[k1];
    byte abyte2[] = new byte[k1];
    for(Enumeration enumeration = colorHash.elements(); enumeration.hasMoreElements();) {
    GifEncoderHashitem gifencoderhashitem1 = (GifEncoderHashitem)enumeration.nextElement();
    abyte0[gifencoderhashitem1.index] = (byte)(gifencoderhashitem1.rgb >> 16 & 0xff);
    abyte1[gifencoderhashitem1.index] = (byte)(gifencoderhashitem1.rgb >> 8 & 0xff);
    abyte2[gifencoderhashitem1.index] = (byte)(gifencoderhashitem1.rgb & 0xff);
    GIFEncode(super.out, width, height, interlace, (byte)0, i, byte0, abyte0, abyte1, abyte2);
    byte GetPixel(int i, int j) throws IOException {
    GifEncoderHashitem gifencoderhashitem = (GifEncoderHashitem)colorHash.get(rgbPixels[j][i]);
    if(gifencoderhashitem == null)
    throw new IOException("color not found");
    else
    return (byte)gifencoderhashitem.index;
    static void writeString(OutputStream outputstream, String s) throws IOException {
    byte abyte0[] = s.getBytes();
    outputstream.write(abyte0);
    void GIFEncode(OutputStream outputstream, int i, int j, boolean flag, byte byte0, int k, int l,
    byte abyte0[], byte abyte1[], byte abyte2[]) throws IOException {
    Width = i;
    Height = j;
    Interlace = flag;
    int k1 = 1 << l;
    int j1;
    int i1 = j1 = 0;
    CountDown = i * j;
    Pass = 0;
    int l1;
    if(l <= 1)
    l1 = 2;
    else
    l1 = l;
    curx = 0;
    cury = 0;
    writeString(outputstream, "GIF89a");
    Putword(i, outputstream);
    Putword(j, outputstream);
    char c = '\uFF80';
    c |= 'p';
    c |= (byte)(l - 1);
    Putbyte((byte)c, outputstream);
    Putbyte(byte0, outputstream);
    Putbyte((byte)0, outputstream);
    for(int i2 = 0; i2 < k1; i2++) {
    Putbyte(abyte0[i2], outputstream);
    Putbyte(abyte1[i2], outputstream);
    Putbyte(abyte2[i2], outputstream);
    if(k != -1) {
    Putbyte((byte)33, outputstream);
    Putbyte((byte)-7, outputstream);
    Putbyte((byte)4, outputstream);
    Putbyte((byte)1, outputstream);
    Putbyte((byte)0, outputstream);
    Putbyte((byte)0, outputstream);
    Putbyte((byte)k, outputstream);
    Putbyte((byte)0, outputstream);
    Putbyte((byte)44, outputstream);
    Putword(i1, outputstream);
    Putword(j1, outputstream);
    Putword(i, outputstream);
    Putword(j, outputstream);
    if(flag)
    Putbyte((byte)64, outputstream);
    else
    Putbyte((byte)0, outputstream);
    Putbyte((byte)l1, outputstream);
    compress(l1 + 1, outputstream);
    Putbyte((byte)0, outputstream);
    Putbyte((byte)59, outputstream);
    void BumpPixel() {
    curx++;
    if(curx == Width) {
    curx = 0;
    if(!Interlace) {
    cury++;
    return;
    switch(Pass) {
    default:
    break;
    case 0: // '\0'
    cury += 8;
    if(cury >= Height) {
    Pass++;
    cury = 4;
    return;
    break;
    case 1: // '\001'
    cury += 8;
    if(cury >= Height) {
    Pass++;
    cury = 2;
    return;
    break;
    case 2: // '\002'
    cury += 4;
    if(cury >= Height) {
    Pass++;
    cury = 1;
    return;
    break;
    case 3: // '\003'
    cury += 2;
    return;
    int GIFNextPixel() throws IOException {
    if(CountDown == 0) {
    return -1;
    } else {
    CountDown--;
    byte byte0 = GetPixel(curx, cury);
    BumpPixel();
    return byte0 & 0xff;
    void Putword(int i, OutputStream outputstream) throws IOException {
    Putbyte((byte)(i & 0xff), outputstream);
    Putbyte((byte)(i >> 8 & 0xff), outputstream);
    void Putbyte(byte byte0, OutputStream outputstream) throws IOException {
    outputstream.write(byte0);
    final int MAXCODE(int i) {
    return (1 << i) - 1;
    void compress(int i, OutputStream outputstream) throws IOException {
    g_init_bits = i;
    clear_flg = false;
    n_bits = g_init_bits;
    maxcode = MAXCODE(n_bits);
    ClearCode = 1 << i - 1;
    EOFCode = ClearCode + 1;
    free_ent = ClearCode + 2;
    char_init();
    int j1 = GIFNextPixel();
    int i2 = 0;
    for(int j = hsize; j < 0x10000; j *= 2)
    i2++;
    i2 = 8 - i2;
    int l1 = hsize;
    cl_hash(l1);
    output(ClearCode, outputstream);
    int i1;
    label0:
    while((i1 = GIFNextPixel()) != -1) {
    int k = (i1 << maxbits) + j1;
    int l = i1 << i2 ^ j1;
    if(htab[l] == k) {
    j1 = codetab[l];
    continue;
    if(htab[l] >= 0) {
    int k1 = l1 - l;
    if(l == 0)
    k1 = 1;
    do {
    if((l -= k1) < 0)
    l += l1;
    if(htab[l] == k) {
    j1 = codetab[l];
    continue label0;
    } while(htab[l] >= 0);
    output(j1, outputstream);
    j1 = i1;
    if(free_ent < maxmaxcode) {
    codetab[l] = free_ent++;
    htab[l] = k;
    } else {
    cl_block(outputstream);
    output(j1, outputstream);
    output(EOFCode, outputstream);
    void output(int i, OutputStream outputstream) throws IOException {
    cur_accum &= masks[cur_bits];
    if(cur_bits > 0)
    cur_accum |= i << cur_bits;
    else
    cur_accum = i;
    for(cur_bits += n_bits; cur_bits >= 8; cur_bits -= 8) {
    char_out((byte)(cur_accum & 0xff), outputstream);
    cur_accum >>= 8;
    if(free_ent > maxcode || clear_flg)
    if(clear_flg) {
    maxcode = MAXCODE(n_bits = g_init_bits);
    clear_flg = false;
    } else {
    n_bits++;
    if(n_bits == maxbits)
    maxcode = maxmaxcode;
    else
    maxcode = MAXCODE(n_bits);
    if(i == EOFCode) {
    for(; cur_bits > 0; cur_bits -= 8) {
    char_out((byte)(cur_accum & 0xff), outputstream);
    cur_accum >>= 8;
    flush_char(outputstream);
    void cl_block(OutputStream outputstream) throws IOException {
    cl_hash(hsize);
    free_ent = ClearCode + 2;
    clear_flg = true;
    output(ClearCode, outputstream);
    void cl_hash(int i) {
    for(int j = 0; j < i; j++)
    htab[j] = -1;
    void char_init() {
    a_count = 0;
    void char_out(byte byte0, OutputStream outputstream) throws IOException {
    accum[a_count++] = byte0;
    if(a_count >= 254)
    flush_char(outputstream);
    void flush_char(OutputStream outputstream) throws IOException {
    if(a_count > 0) {
    outputstream.write(a_count);
    outputstream.write(accum, 0, a_count);
    a_count = 0;
    private boolean interlace;
    int width;
    int height;
    int rgbPixels[][];
    IntHashtable colorHash;
    int Width;
    int Height;
    boolean Interlace;
    int curx;
    int cury;
    int CountDown;
    int Pass;
    static final int EOF = -1;
    static final int BITS = 12;
    static final int HSIZE = 5003;
    int n_bits;
    int maxbits;
    int maxcode;
    int maxmaxcode;
    int htab[];
    int codetab[];
    int hsize;
    int free_ent;
    boolean clear_flg;
    int g_init_bits;
    int ClearCode;
    int EOFCode;
    int cur_accum;
    int cur_bits;
    int masks[] = {
    0, 1, 3, 7, 15, 31, 63, 127, 255, 511,
    1023, 2047, 4095, 8191, 16383, 32767, 65535
    int a_count;
    byte accum[];

Maybe you are looking for