Image Resize: InputStream - BufferedImage

Hi,
I'm in a position where I'm forced to use Java SE 1.3.1_19. We use Oracle 9iAS and aren't in a position to upgrade at present.
I know in JavaSE1.5 I can use ImageIO etc to resize images on the fly because I have written a class to do this. How can I replicated this functionality in 1.3.1_19?
My requirements are to upload via a multipart form (using Org.Apache.Commons.FileUpload) an Image to a BLOB field in an Oracle DB. If any one can suggest a way to do this with v1.3.1_19 I would very much appreciate it.

import java.awt.*;
import java.awt.event.*;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.io.*;
import javax.swing.*;
public class ScalingTest {
    private JScrollPane getContent() {
        Image orig = loadImage();
        BufferedImage scaled = getScaledImage(orig, 0.50);
        JPanel panel = new JPanel(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.insets = new Insets(5,5,5,5);
        gbc.weightx = 1.0;
        panel.add(new JLabel(new ImageIcon(orig)), gbc);
        panel.add(new JLabel(new ImageIcon(scaled)), gbc);
        return new JScrollPane(panel);
    private Image loadImage() {
        String path = "images/cougar.jpg";
        InputStream is = getClass().getResourceAsStream(path);
        byte[] imageData = readData(is);
        ImageIcon icon = new ImageIcon(imageData);
        Image image = icon.getImage();
        // ImageIcon does not let you know if the image was not
        // successfully loaded so you must ask it for feedback.
        int status = icon.getImageLoadStatus();
        String result = "";
        switch(status) {
            case MediaTracker.ABORTED:
                result = "ABORTED";
                break;
            case MediaTracker.ERRORED:
                result = "ERRORED";
                break;
            case MediaTracker.COMPLETE:
                result = "COMPLETE";
                break;
            default:
                result = "unexpected loadingStatus: " + status;
        System.out.println("Loading status for \"" + path + "\": " + result);
        return image;
    private byte[] readData(InputStream is) {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        try {
            byte[] buffer = new byte[4096];
            int len, count = 0;
            while((len = is.read(buffer)) != -1) {
                baos.write(buffer, 0, len);
                count += len;
            is.close();
            System.out.println("image size = " + count);
        } catch(IOException e) {
            System.out.println("read error: " + e.getMessage());
        return baos.toByteArray();
    private BufferedImage getScaledImage(Image image, double scale) {
        int w = (int)(scale*image.getWidth(null));
        int h = (int)(scale*image.getHeight(null));
        int type = BufferedImage.TYPE_INT_RGB;
        BufferedImage out = new BufferedImage(w, h, type);
        Graphics2D g2 = out.createGraphics();
        AffineTransform at = AffineTransform.getScaleInstance(scale, scale);
        g2.drawImage(image, at, null);
        g2.dispose();
        return out;
    public static void main(String[] args) {
        JFrame f = new JFrame();
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.getContentPane().add(new ScalingTest().getContent());
        f.setSize(400,400);
        f.setLocation(200,200);
        f.setVisible(true);
}

Similar Messages

  • Image-resize servlet

    Hi,
    I�ve been working on an image-resizing servlet on and off for quite some time now, and I just cant seem to get it to load the image correctly.
    I guess its very simple once you figure it out. The following is the interesting part:
    Image image = Toolkit.getDefaultToolkit().getImage("../pictures/pic" + pictureId + ".jpg");
    MediaTracker tracker = new MediaTracker( new JFrame() );
    tracker.addImage(image, 1);
    // Load image
    try {
      tracker.waitForAll();
    } catch (InterruptedException e) {}
    // Scale image
    image = image.getScaledInstance(width, height, Image.SCALE_DEFAULT);I then copy the Graphics from the Image to another Graphics before it is sent to the client (have some cache-stuff going on in the middle), but all images turn out beeing plain black.
    Anyone with ideas/sample code?

    hi flaperman
    i did something similar in my resizing servlet:
    BufferedImage image = ImageIO.read(new File(path));
    Image im = image.getScaledInstance(width, height, Image.SCALE_FAST);
    BufferedImage thumbnail = toBufferedImage(im);
    ImageIO.write(thumbnail, "jpeg", response.getOutputStream());
    i found the code of the method toBufferedImage() on the following page http://developers.sun.com/solaris/tech_topics/java/articles/awt.html
    maybe this will help you. but i'm afraid it is slow and it seems to be leaking memory (a lot).
    cheers

  • Image Resizing Problem

    Hello,
    I am working on image project. The task which I want to do is to resize the image. I am using normal java.awt.image package. The classes which I am using are AffineTransformOp for scaling an image, Graphics and BufferedImage etc. The problem is when I scaled down an image of large image to low image (e.g. 800 x 800 to 160x160), The image gets blued or some pixels are looking stretched. I have tried severl other 3rd party APIs but failed. However if i conver 400x400 image to 160x160 .. it works fine. I need quick help..plz if somebody can suggest any solution..
    Thanks

    try {
         AffineTransformOp op = null;
    BufferedImage tempImage;
    double xScale = (double)((double)x/(double)width);
    double yScale = (double)((double)y/(double)height);
              BufferedImage outImage;
              OutputStream os;          
    op = new AffineTransformOp(AffineTransform.getScaleInstance(xScale,yScale),AffineTransformOp.TYPE_BILINEAR);     tempImage = op.filter(original, null);           
    } catch (ImagingOpException e) {
    e.printStackTrace();
    System.out.println("Exception while creating imgages");
         }

  • Floating point image resize?

    I can't find any method which allows a floating-point image sizing.
    I guess what I need is something like
    float x, y, width, height;
    g2d.drawImage(image, x, y, 0, width, height, null);
    Is such a thing possible in Swing?
    I'm animating a shrinking icon and the icon sways slightly from side to size due to inability to resize to n.5 pixels. The alternative I have is to only resize to even numbers of pixels, but this looks very jerky.
    Thanks

    Thanks, the AffineTransform approach works perfectly, no more wobbling.
    The code which works for me is ...
        public static BufferedImage scaleCentered(Image image, float scaleX, float scaleY)
            int type = BufferedImage.TYPE_INT_ARGB;
            int width=image.getWidth(null);
            int height=image.getHeight(null);
            BufferedImage result=new BufferedImage(width, height, type);
            Graphics2D g2d = result.createGraphics();
            g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
            float centerX=image.getWidth(null) / 2;
            float centerY=image.getHeight(null) / 2;
            AffineTransform transform=new AffineTransform();
            transform.translate(centerX,  centerY);
            transform.scale(scaleX, scaleY);
            transform.translate(-centerX, -centerY);
            g2d.setTransform(transform);
            g2d.drawImage(image, 0, 0, width, height, null);
            g2d.dispose();
            return result;
        }  

  • Image Resizing Using Java

    Hi.
    I am new to Java and have a question.
    I have an image at this path: "c:\images\pic1.gif".
    I want to take this image, resize it, and save it to a different path.
    I don't have any outside Toolkits.
    How do I do this?
    Or, more simply, how do I use the Image and BufferedImage classes?
    I cannot figure out how to create a BufferedImage object using the path for the image I have.
    Thanks in anticipation.

    the article referred by previous answer is pretty good, but you can do it simpler. Just:
    1. create buffered image
    2. get graphics
    3. draw your source image in the graphics with desired size
    Check for an implementation
    http://mediachest.sourceforge.net/download/MediaChest11-80.zip

  • Proportional Image Resizing

    Hi,
    Description of the task:
    I need to upload two images one is a full image and the other is a thumbnail representation of the same image of type jpg. I also need to ensure that all the uploaded images are within a given maximun size. For example:
    Thumbs should be 76 x 55 pixels
    FullSized should be 247 x 183 pixels
    Task Achievements:
    I've used the apachee commons package's FileItem class to handle retrival and storage of the image from the submitting servelet form.
    Description of the Problem:
    Don't know how to apply a proportional resize on the uploaded files (images) before storing them.
    Other Questions:
    1. Will the fact that conventional Buffered approach for reading files being not used hamper file manipulation?
    2. Can a proportional Image resizing function be applied to images in java. (Similar to that of php)
    3. Can an external php file be called or accessed from within java (a servlet) to perform the same functions of uploading an image and resizing it porportionally.

    private void uploadThumbImage(FileItem thumbImage, int eventId) throws JspException
         // code for fikle uploade goes here
         try
          //write the orginalFiles
          thumbImage.write(orginalThumbNail);
          resizeThumb(eventId);
         catch(Exception e)
             ErrorPrinter(e.getMessage()+" Exception in Image Upload");
    private void resizeThumb(int eventId) throws JspException
         try
              File loc = new File ("c:/"+eventId+".jpg");
              BufferedImage storedImage = ImageIO.read(loc);
              //ASSIGN  MAXIMUM X AND Y FOR STORAGE
              //1. set the expected allowable x and y maximum
              double maxiumX = 75;
              double maxiumY = 55;
              //2. check that the image is not too long or too wide
              double imgHeight = storedImage.getHeight()*1.0;
              double imgWidth = storedImage.getWidth()*1.0;
              if (imgHeight > maxiumY*2 && imgWidth > maxiumX*2)
                maxiumX = maxiumX*1;
                maxiumY = maxiumX*1;
              else if (imgHeight > maxiumY*2)
                maxiumY = maxiumY*2;
              else if (imgWidth > maxiumY*2)
                maxiumX = maxiumX*2;
              //3. Scale for the width (x)
              if (imgWidth > maxiumX)
               imgHeight = imgHeight*(maxiumX/imgWidth);
               imgWidth = maxiumX;
              //4. Scale for the lenght (l)
              if (imgHeight > maxiumY)
                   imgHeight = maxiumY;
                   imgWidth = imgWidth*(maxiumY/imgHeight);
              Image testImage = storedImage.getScaledInstance((int)imgWidth,(int)imgHeight,Image.SCALE_AREA_AVERAGING);
              BufferedImage biRescaled = toBufferedImage(testImage, BufferedImage.TYPE_INT_RGB);
              if (loc.exists())
                   if(!loc.delete())
                        ErrorPrinter("File that already exisits with file name could not be removed - (Thumbnail)");
              ImageIO.write(biRescaled, "jpg", new File ("c:/et_"+eventId+".jpg"));
              catch (IOException e)
                   ErrorPrinter(e.getMessage()+" Exception in Image Resize");
              catch(Exception e)
                   ErrorPrinter(e.getMessage()+" Exception in Image Resize");
    private static BufferedImage toBufferedImage(Image image, int type)
            int w = image.getWidth(null);
            int h = image.getHeight(null);
            BufferedImage result = new BufferedImage(w, h, type);
            return result;
       }

  • Ways to implement image resizing using plug-ins?

    Hi Photoshop developers,
    I'm a developer with a few Photoshop filter and selection plug-ins under my belt, and I have a good understanding of the SDK and tools and suites it provides. My next project is an algorithm for enlarging/resampling images to different pixel dimensions. I'm wondering if anyone has any suggestions for or experience with the best combination of plug-in types to implement this.
    Clearly, I can't just write it as a filter plug-in, since there is no way to change the image dimensions from within a filter.
    I'd like the resized image to remain within Photoshop (as a new window or in the original one), so an export plug-in on its own is not sufficient.
    Import plug-ins seem promising, since they allow the creation of a new document of the required size. However, as best I can tell from the Photoshop 6.0 SDK documentation, import plug-ins cannot access the image data from other open documents (or even the clipboard), nor do they provide any support for channel ports and the Channel Port suite.
    My best idea at this stage is to create an export plug-in to provide the user interface and calculate the resized image, and then an import plug-in to import the resized image back into a new window. (I'm supposing a further automation plug-in would then be written to perform this export/import sequence.) The difficulty I see with this approach is how to communicate the resized image data between the two plug-ins. Since the resized image will potentially be very large, the ideal solution would be to store it in channels managed by the Channel Ports suite. However, I cannot see how the channel ports created in the export plug-in could be communicated to and used by an import plug-in. The alternative would be for the export plug-in to save the resized image to a temporary file on disk, however this seems unnecessary.
    So, my questions, specifically, are:
    a) Is it possible to create new channels using the Channel Ports suite (sPSChannelPorts->New()) in one plug-in, and have those channels persist to be used in another plug-in?
    b) If so, how would the channel ports be communicated between the plug-ins?
    c) Alternately, are there any alternative architectures available for implementing an image-resizing algorithm using the plug-in types that are available for Photoshop developers.
    Any responses would be greatly appreciated; I know this is a low-traffic forum...
    Thanks,
    Matthew.

    I would make an automation plug-in and a filter plug-in.<br /><br />1) Run the automation which runs your filter to gather current image <br />information<br />2) Create a temp file of the new document<br />3) Make a new document<br />4) Call the filter again to reload the temp data on disk<br /><br /><[email protected]> wrote in message <br />news:[email protected]...<br />> Hi Photoshop developers,<br />><br />> I'm a developer with a few Photoshop filter and selection plug-ins under <br />> my belt, and I have a good understanding of the SDK and tools and suites <br />> it provides. My next project is an algorithm for enlarging/resampling <br />> images to different pixel dimensions. I'm wondering if anyone has any <br />> suggestions for or experience with the best combination of plug-in types <br />> to implement this.<br />><br />> Clearly, I can't just write it as a filter plug-in, since there is no way <br />> to change the image dimensions from within a filter.<br />><br />> I'd like the resized image to remain within Photoshop (as a new window or <br />> in the original one), so an export plug-in on its own is not sufficient.<br />><br />> Import plug-ins seem promising, since they allow the creation of a new <br />> document of the required size. However, as best I can tell from the <br />> Photoshop 6.0 SDK documentation, import plug-ins cannot access the image <br />> data from other open documents (or even the clipboard), nor do they <br />> provide any support for channel ports and the Channel Port suite.<br />><br />> My best idea at this stage is to create an export plug-in to provide the <br />> user interface and calculate the resized image, and then an import plug-in <br />> to import the resized image back into a new window. (I'm supposing a <br />> further automation plug-in would then be written to perform this <br />> export/import sequence.) The difficulty I see with this approach is how to <br />> communicate the resized image data between the two plug-ins. Since the <br />> resized image will potentially be very large, the ideal solution would be <br />> to store it in channels managed by the Channel Ports suite. However, I <br />> cannot see how the channel ports created in the export plug-in could be <br />> communicated to and used by an import plug-in. The alternative would be <br />> for the export plug-in to save the resized image to a temporary file on <br />> disk, however this seems unnecessary.<br />><br />> So, my questions, specifically, are:<br />><br />> a) Is it possible to create new channels using the Channel Ports suite <br />> (sPSChannelPorts->New()) in one plug-in, and have those channels persist <br />> to be used in another plug-in?<br />><br />> b) If so, how would the channel ports be communicated between the <br />> plug-ins?<br />><br />> c) Alternately, are there any alternative architectures available for <br />> implementing an image-resizing algorithm using the plug-in types that are <br />> available for Photoshop developers.<br />><br />> Any responses would be greatly appreciated; I know this is a low-traffic <br />> forum...<br />><br />> Thanks,<br />> Matthew.

  • Images as Buttons and Image Resizing in mxml

    Sorry for all the questions but I've run into a problem when trying to create buttons that are just an image in mxml. When I first tried this I couldn't find a way to get the border around the button to dissapear so it ended up looking like my image had an extra black border around it. Then someone here suggested I just set the buttonMode property of an mx:Image to true which ended up working fine to a point. The problem I'm having is that even if I make the tabEnabled property of the image (that I'm using as a button) true, I can't tab over to it. Is there a way to either get rid of the black borders of a button or to make it so I can tab over to an image I'm using as a button?
    My second question has to do with image resizing. Lets say I have an image of a horizontal line that I want to put at the top of the mxml page, and I want it to extend the full length of the page, even after the user has resized the browser. Is there a way to do that? I've tried putting the width as 100% or giving the image a "left" and "right" value so that presumably it would be stretched to fit within those but nothing has worked so far. Is there no way to do this or am I doing something wrong?
    Thank you for any help you guys can give.

    Of course, sorry about that. So the following is a barebones example of how I currently implement buttons and images as buttons:
    <mx:Button id="facebookButton" icon="@Embed(source='image.png')" width="30"/>
    <mx:Image buttonMode="true" id="button" source="anotherimage.png" enabled="true" click="{foo()}"/>
    And within the image I've tried making the tabFocusEnabled property true but to no avail.
    The following is how I've tried stretching out an image across the whole page:
    <mx:Image source="yetanotherimage.png" width="100%" scaleContent="true"/>
    <mx:Image source="yetanotherimage.png" left="10" right="10" scaleContent="true"/>
    Is this more helpful?

  • Why won't Photoshop revert to earlier history state after image resize when scripted?

    I've written an Applescript to automate watermarking and resizing images for my company. Everything generally works fine — the script saves the initial history state to a variable, resizes the image, adds the appropriate watermark, saves off a jpeg, then reverts to the initial history state for another resize and watermark loop.
    The problem is when I try not to use a watermark and only resize by setting the variable `wmColor` to `"None"` or `"None for all"`. It seems that after resizing and saving off a jpeg, Photoshop doesn't like it when I try to revert to the initial history state. This is super annoying, since clearly a resize should count as a history step, and I don't want to rewrite the script to implement multiple open/close operations on the original file. Does anyone know what might be going on? This is the line that's generating the problem (it's in both the doBig and doSmall methods, and throws an error every time I ask it just to do an image resize and change current history state):
                        set current history state of current document to initialState
    and here's the whole script:
    property type_list : {"JPEG", "TIFF", "PNGf", "8BPS", "BMPf", "GIFf", "PDF ", "PICT"}
    property extension_list : {"jpg", "jpeg", "tif", "tiff", "png", "psd", "bmp", "gif", "jp2", "pdf", "pict", "pct", "sgi", "tga"}
    property typeIDs_list : {"public.jpeg", "public.tiff", "public.png", "com.adobe.photoshop-image", "com.microsoft.bmp", "com.compuserve.gif", "public.jpeg-2000", "com.adobe.pdf", "com.apple.pict", "com.sgi.sgi-image", "com.truevision.tga-image"}
    global myFolder
    global wmYN
    global wmColor
    global nameUse
    global rootName
    global nameCount
    property myFolder : ""
    -- This droplet processes files dropped onto the applet
    on open these_items
      -- FILTER THE DRAGGED-ON ITEMS BY CHECKING THEIR PROPERTIES AGAINST THE LISTS ABOVE
              set wmColor to null
              set nameCount to 0
              set nameUse to null
              if myFolder is not "" then
                        set myFolder to choose folder with prompt "Choose where to put your finished images" default location myFolder -- where you're going to store the jpgs
              else
                        set myFolder to choose folder with prompt "Choose where to put your finished images" default location (path to desktop)
              end if
              repeat with i from 1 to the count of these_items
                        set totalFiles to count of these_items
                        set this_item to item i of these_items
                        set the item_info to info for this_item without size
                        if folder of the item_info is true then
      process_folder(this_item)
                        else
                                  try
                                            set this_extension to the name extension of item_info
                                  on error
                                            set this_extension to ""
                                  end try
                                  try
                                            set this_filetype to the file type of item_info
                                  on error
                                            set this_filetype to ""
                                  end try
                                  try
                                            set this_typeID to the type identifier of item_info
                                  on error
                                            set this_typeID to ""
                                  end try
                                  if (folder of the item_info is false) and (alias of the item_info is false) and ((this_filetype is in the type_list) or (this_extension is in the extension_list) or (this_typeID is in typeIDs_list)) then
      -- THE ITEM IS AN IMAGE FILE AND CAN BE PROCESSED
      process_item(this_item)
                                  end if
                        end if
              end repeat
    end open
    -- this sub-routine processes folders
    on process_folder(this_folder)
              set these_items to list folder this_folder without invisibles
              repeat with i from 1 to the count of these_items
                        set this_item to alias ((this_folder as Unicode text) & (item i of these_items))
                        set the item_info to info for this_item without size
                        if folder of the item_info is true then
      process_folder(this_item)
                        else
                                  try
                                            set this_extension to the name extension of item_info
                                  on error
                                            set this_extension to ""
                                  end try
                                  try
                                            set this_filetype to the file type of item_info
                                  on error
                                            set this_filetype to ""
                                  end try
                                  try
                                            set this_typeID to the type identifier of item_info
                                  on error
                                            set this_typeID to ""
                                  end try
                                  if (folder of the item_info is false) and (alias of the item_info is false) and ((this_filetype is in the type_list) or (this_extension is in the extension_list) or (this_typeID is in typeIDs_list)) then
      -- THE ITEM IS AN IMAGE FILE AND CAN BE PROCESSED
      process_item(this_item)
                                  end if
                        end if
              end repeat
    end process_folder
    -- this sub-routine processes files
    on process_item(this_item)
              set this_image to this_item as text
              tell application id "com.adobe.photoshop"
                        set saveUnits to ruler units of settings
                        set display dialogs to never
      open file this_image
                        if wmColor is not in {"None for all", "White for all", "Black for all"} then
                                  set wmColor to choose from list {"None", "None for all", "Black", "Black for all", "White", "White for all"} with prompt "What color should the watermark be?" default items "White for all" without multiple selections allowed and empty selection allowed
                        end if
                        if wmColor is false then
                                  error number -128
                        end if
                        if nameUse is not "Just increment this for all" then
                                  set nameBox to display dialog "What should I call these things?" default answer ("image") with title "Choose the name stem for your images" buttons {"Cancel", "Just increment this for all", "OK"} default button "Just increment this for all"
                                  set nameUse to button returned of nameBox -- this will determine whether or not to increment stem names
                                  set rootName to text returned of nameBox -- this will be the root part of all of your file names
                                  set currentName to rootName
                        else
                                  set nameCount to nameCount + 1
                                  set currentName to rootName & (nameCount as text)
                        end if
                        set thisDocument to current document
                        set initialState to current history state of thisDocument
                        set ruler units of settings to pixel units
              end tell
      DoSmall(thisDocument, currentName, initialState)
      DoBig(thisDocument, currentName, initialState)
              tell application id "com.adobe.photoshop"
                        close thisDocument without saving
                        set ruler units of settings to saveUnits
              end tell
    end process_item
    to DoSmall(thisDocument, currentName, initialState)
              tell application id "com.adobe.photoshop"
                        set initWidth to width of thisDocument
                        if initWidth < 640 then
      resize image thisDocument width 640 resample method bicubic smoother
                        else if initWidth > 640 then
      resize image thisDocument width 640 resample method bicubic sharper
                        end if
                        set myHeight to height of thisDocument
                        set myWidth to width of thisDocument
                        if wmColor is in {"White", "White for all"} then
                                  set wmFile to (path to resource "water_250_white.png" in bundle path to me) as text
                        else if wmColor is in {"Black", "Black for all"} then
                                  set wmFile to (path to resource "water_250_black.png" in bundle path to me) as text
                        end if
                        if wmColor is not in {"None", "None for all"} then
      open file wmFile
                                  set wmDocument to current document
                                  set wmHeight to height of wmDocument
                                  set wmWidth to width of wmDocument
      duplicate current layer of wmDocument to thisDocument
                                  close wmDocument without saving
      translate current layer of thisDocument delta x (myWidth - wmWidth - 10) delta y (myHeight - wmHeight - 10)
                                  set opacity of current layer of thisDocument to 20
                        end if
                        set myPath to (myFolder as text) & (currentName) & "_640"
                        set myOptions to {class:JPEG save options, embed color profile:false, quality:12}
      save thisDocument as JPEG in file myPath with options myOptions appending lowercase extension
                        set current history state of current document to initialState
              end tell
    end DoSmall
    to DoBig(thisDocument, currentName, initialState)
              tell application id "com.adobe.photoshop"
                        set initWidth to width of thisDocument
                        if initWidth < 1020 then
      resize image thisDocument width 1020 resample method bicubic smoother
                        else if initWidth > 1020 then
      resize image thisDocument width 1020 resample method bicubic sharper
                        end if
                        set myHeight to height of thisDocument
                        set myWidth to width of thisDocument
                        if wmColor is in {"White", "White for all"} then
                                  set wmFile to (path to resource "water_400_white.png" in bundle path to me) as text
                        else if wmColor is in {"Black", "Black for all"} then
                                  set wmFile to (path to resource "water_400_black.png" in bundle path to me) as text
                        end if
                        if wmColor is not in {"None", "None for all"} then
      open file wmFile
                                  set wmDocument to current document
                                  set wmHeight to height of wmDocument
                                  set wmWidth to width of wmDocument
      duplicate current layer of wmDocument to thisDocument
                                  close wmDocument without saving
      translate current layer of thisDocument delta x (myWidth - wmWidth - 16) delta y (myHeight - wmHeight - 16)
                                  set opacity of current layer of thisDocument to 20
                        end if
                        set myPath to (myFolder as text) & (currentName) & "_1020"
                        set myOptions to {class:JPEG save options, embed color profile:false, quality:12}
      save thisDocument as JPEG in file myPath with options myOptions appending lowercase extension
                        set current history state of current document to initialState
              end tell
    end DoBig

    As many others here I use JavaScript so I can’t really help you with your problem.
    But I’d like to point to »the lazy person’s out« – with many operations that result in creating a new file on disk I simply duplicate the image (and flatten in the same step) to minimize any chance of damaging the original file if the Script should not perform as expected.

  • Image resizing in Smartforms?? or ADOBE

    Hello All,
    I am working on creating a smartform. It includes displaying images in the output. There could be different
    smartforms displaying the same image but with different sizes.
    I know of the solution to resize the image using picture editor and upload using SE78, which is then accessed in the smartform. But I want to avoid multiple sizes of same images in the MIME repository.
    Is there a possibility of image resizing in the smartform ? If yes, then how ? I have tried changing the DPI in General attributes of the graphic node in smartform but it does not resize the image.
    If not, then is it possible in ADOBE forms ?
    Regards,
    Subodh S.Rao

    Hi Subuodh,
    Please refer to the gabriels answer in the below link.
    http://scn.sap.com/thread/506094
    Other Ways of doing.
    http://wiki.sdn.sap.com/wiki/display/ABAP/SE78+And+OAER+bmp+Image+Creating
    Hope it will help.
    Regards,
    Amit

  • PHP -Mysql image resize and upload

    All,
    Any good ideas, code out there to help me do a PHP MySQL image resize, uploade and display? Thanks for your help!

    For upload image, u may look at the similar thread HERE

  • Permissions issue with image resize

    Ok I'm hoping someone may be able to help with this because it is really frustrating.
    I realise this issue has already been posted in these forums however there was no solution offered that has rectified it for me.  I am getting an error when trying to display thumbnails        "Error converting image (create thumbnail). The "" folder has no write permissions".  And this error when trying to upload and resize images "Image upload error. Error resizing image: Error converting image (image resize). The "" folder has no write permissions. (IMG_RESIZE)". All folders on server have full read, write and execute permissions, so I am really confused why this happenning.  I have removed and updated the includes folder on the server with no joy.  I altered the tNG_custom.class.php, tNG_insert.class.php, tNG_update.class.php files to remove the tNG_fields line to just tNG as this was throwing errors with PHP5.3.  I also changed everything else per http://forums.adobe.com/message/2357443#2357443.
    This is the tNG execution trace (why the tNGUNKNOWN??):-
    tNGUNKNOWN.executeTransaction
    STARTER.Trigger_Default_Starter
    tNGUNKNOWN.doTransaction
    BEFORE.Trigger_Default_FormValidation
    BEFORE.Trigger_CheckForbiddenWords
    tNG_insert.prepareSQL
    tNGUNKNOWN.executeTransaction - execute sql
    tNG_insert.postExecuteSql
    AFTER.Trigger_ImageUploadtNGUNKNOWN.afterUpdateField - DefaultPic, P8280176.JPG*
    ERROR.Trigger_LinkTransactionstNGUNKNOWN.doTransaction
    tNGUNKNOWN.executeTransaction
    tNGUNKNOWN.getRecordset
    tNGUNKNOWN.getFakeRsArr
    tNG_insert.getLocalRecordset
    tNGUNKNOWN.getFakeRecordset
    tNGUNKNOWN.getFakeRecordset
    tNGUNKNOWN.getRecordset
    tNGUNKNOWN.getFakeRsArr
    tNG_insert.getLocalRecordset
    tNGUNKNOWN.getFakeRecordset
    tNGUNKNOWN.getFakeRecordset
    And is causing the following php warnings when executed:-
    Warning: Parameter 2 to Trigger_Default_FormValidation() expected to be a reference, value given /testing/includes/tng/tNG.class.php on line 228 Warning: preg_split(): No ending matching delimiter ']' found in /testing/includes/common/lib/image/KT_Image.class.php on line 2034 Warning: array_pop() expects parameter 1 to be array, boolean given in /testing/includes/common/lib/image/KT_Image.class.php on line 2035 Warning: implode(): Invalid arguments passed in /testing/includes/common/lib/image/KT_Image.class.php on line 203
    Is it the preg_split() that is causing the issues here??
    Any Ideas?

    Hello BoarderLineLtd
    I have noticed that on some servers when you upload the first image to the images folder using the ADDT image upload function the thumbnail directory that gets written to the images directory is written but the permissions are not set.
    If you use an FTP program such as CuteFTP or WSFTP to login to your web site you can manually set the permissions for the thumbnail directory.
    This should eliminate the permissions error.
    Stan Forrest
    Senior Web Developer
    Digital Magic Show

  • PSE newbie frustrated, please help with image resizing

    Hi!
    Tutorials aren't helping me, nor is trial and error. I just want to resize some photos I downloaded to my computer, then upload them to a website to use as my avatar or signature. There are specific pixel dimensions I must adhere to. I want to keep the photo in it's entirety, but when I resize it, it distorts a bit, looks fuzzy...
    I can't figure out what the heck I am doing wrong. Some pictures turn out just fine and others look really bad. I know it can be done because I've seen the same pictures I'm trying to size, being used for the same thing I want to use them for, but theirs are clear, absolutely no distortion whatsoever. The pixel dimensions I have to work with are either 100x100, or 450 pixels wide by 90 pixels high.
    I hope this made sense, I'm not sure how else to word it. Please forgive my ignorance, I've really been trying.
    Thank-you
    B

    For an avatar it’s possibly best to crop to begin with so you get a true square.
    Open the image and select the crop tool and change the aspect ratio to 1 x 1 or 5 x 5 then drag out a square and move the image around inside it or drag the bounding box borders until you have it looking as you want. Then click the green check mark.
    On the top menu click Image > Resize > Image Size and in either the height or width box type 100 px (you only need to type the dimension once the other box will change to 100 automatically. Make sure you have the bottom three boxes checked:
    Scale Styles
    Constrain Proportions
    Resample Image
    With all three checked set the bottom dropdown to Bicubic and then hit OK.
    If you want to apply some sharpening select Enhance on the top menu and choose Unsharp Mask.
    Make sure the Radius is no more than 1.5 and use the amount slider to get the image looking as you want it then save.
      

  • How to make image resizable using mouse ?

    Hi,
    I want to know about that how to resize image by using mouse in Java Canvas. I created some tools like line, free hand, eraser. And want to know how to make an image resizable in canvas by using mouse. An image is jpeg, png, or gif format. I want to make image stretch and shrink by using mouse.
    Please help me..
    Thnax in advance.
    Manveer

    You make a listener to handle the mouse event that you want to capture, then program the affect you want using the event as the trigger.

  • Photshop CS6 image resizing tool.

    Five time I have entered a support question but it does not seem to appear in the lists nor have I had a response, am I entering my request incorrectly?
    My request is:
    I have a PC using Windows 7. I have Photoshop CS6 which I have been using for some time. Very recently the image, image size tool has stopped working. I open the drop down window and the current size of my image is displayed. I then try and type the required changed size in the box but the box does not accept it. The size remains the same. I have un-installed and re-installed CS6 and put in all the latest updates. The first image I tried, it allowed me to change the size. The second image the resize tool would not allow any changes. We were back to where we started. Elsewhere on the support FAQs it was suggested such problems might be cured by deleting \adobe photo cs6 prefs.psp file. This I have done but still I cannot resize my images.
    Please can someone help me??

    If Photoshop has been working well for you then start acting strange the first thing that should come to you  mind is your Photoshop preferences.  Your Photoshop preferences are Photoshop setting made for your user ID for how you want Photoshop to behave.  Each user ID has there own set of Preference files. These are not installed or removed when you Install or uninstall Photoshop.   So if you un-install and re-install Photoshop your Photoshop preferences remain intact.  If the Problem you are having is caused by a corrupt Photoshop preference file.  You will still have that same problem. Did you try resetting your Photoshop preferences?
    Though the Image size dialog is simple many users do not really understand everything about image resizing.  Using a quick look at the image we see three section Top, Middle and bottom..
    Top section is basicly image file size how many pixels are there in the image.
    Middle Image Print Size.
    Bottom Image Resize Image Controls.
    To understand Image Resize you must start from the bottom.  In the bottom control section  Resample Image is the single control that governs  the whole resizing process.   When "Resample Image"  is NOT checked all other controls have no roll in the resize process they are grayed out as is the top file size section.  The file size will not change the pixel will not change. Note all that is grayed out in the above image.  All that can be change is the print size.  The middle section and all three sizes there are tied together as shown by the lines and link icon.  Change one size there and Photoshop will calculate the other two and display the proper values. All  thee setting in the center are sizes associated with length.  Width number uints, Height number uints. and Resolution number Pixel/unit. Resolution therefore is pixels size and pixels have an aspect ratio. Most image pixel these days are square 1:1 aspect ratio.  Photoshop support non square pixels but can only display image using square pixels display have. 
    So when Resample is not checked. The image has a  Width with a fixed number Pixel, a Height with a fixed number Pixels and Pixel aspect ratio. Setting any one print dimension will also set the other two dimensions.
    When resample is check the other controls in the bottom section become useable and so does the top file section.  Normally you should check Constraint Proportions link Width and Height so your image will not distort during the resize. When you resample an image you wind up with an entirely new image with a different number of pixels. Some image quality has been lost for you either through way some details you had or created some details you did not have.  The image quality will depend on the quality of the pixels you had and how well the interpolation method used worker with those pixels. IMO Adobe Bicubic Automatic is not a good general purpose method to it tend to add many artifacts to image that have been sharpened.
    In newer version of Photoshop CC and CC 2014 Adobe has redesigned the Image Size dialog adding a preview  image display. Made the dimension link icon the constrain proportion control when resample is checked. Also hid the scale style option under a gear icon in the upper right corner.

Maybe you are looking for