Resizing image and looks bad afterward

So image manipulation in java is not my bag. I wrote a program to help save me time with my photography, the idea was that I could point it at a directory and then it would read all the files in that folder that are jpgs and resize them to blog ready sizes. This works really well cept the final images that are produced are not of same quality as say when I used GIMP to resize to the same size/aspect ratio the quality is much different. It looks like its a problem with setting my type perhaps to an only 8bit file? Maybe I am wrong, also goofed with the compression stuff (found code online) to turn the compression to 0 (i.e. no compression)...still no avail. Some code I am using:
    public static BufferedImage scaleImage(BufferedImage image, int imageType,
                 int newWidth, int newHeight) {
             // Make sure the aspect ratio is maintained, so the image is not distorted
             double aspectRatio = (double) image.getWidth() / (double) image.getHeight();
              if(newWidth==-1)
                   newWidth=(int)(newHeight * aspectRatio);
              if(newHeight==-1)
                   newHeight = (int)(newWidth / aspectRatio);
             // Draw the scaled image
             BufferedImage newImage = new BufferedImage(newWidth, newHeight,
                     imageType);
             Graphics2D graphics2D = newImage.createGraphics();
                //I admit little clue as to what im doing with the rendering hints.
             Map map = new HashMap();
             map.put(RenderingHints.KEY_INTERPOLATION,
             RenderingHints.VALUE_INTERPOLATION_BILINEAR);
             map.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
             map.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
             RenderingHints hints = new RenderingHints(map);
             graphics2D.setRenderingHints(hints);
             graphics2D.drawImage(image, 0, 0, newWidth, newHeight, null);
             return newImage;
    then the call to it looks like:
public BufferedImage processLandScapeImage(BufferedImage img)
              int width = Integer.valueOf(theHeight.getText()).intValue(); //my desired width
              return scaleImage(img, BufferedImage.TYPE_INT_RGB, width, -1);
         }So this is close, the files dont look bad but alas... they still aren't the same quality. Should I post a sample of what I get with GIMP and what I get with my little program?
Thanks to anyone who has some pointers...
-Shane

If you don't care about the original source BufferedImage, then you should be able to draw the image onto itself in an incremental fashion. That would avoid the use of intermediate images and consequently not throw the OOM.
Also note that the code in that article has a slight hiccup. If you specify you want higher quality and targetWidth > w || targetHeight > h, then you'll get an infinite loop. So it needs to be structured slightly different (indeed, the intermediate images should probably be flushed since they're being draw to and from at least once).
I didn't realize such a task was so non-trivial.If you're not worried about the speed, then I guess the trivial good-result way would be to use Image#getScaledInstance with the area average parameter. It's not so much that it's too slow for normal consumption (it isn't), it's just that the Graphics way is so much faster.
GIMP probably uses a more sophisticated resampling technique like Lanczos or something.

Similar Messages

  • Resizing Image and Not Keep Aspect Ratio

    Is there a free program to resize images and not keep the original aspect ratio?
    I need to resize loads of images to 100x100 pixels and have tried Image well and IResize yet they do not seem to have an option to not keep the original aspect ratio.
    Thank you
    20" Intel 2GHz Core Duo imac, 2GB Ram, 250 GB HD    

    Hi, Downsize does not seem all that great according to reviews. Why not see if you can buy PS E' 3 mac -- maybe ebay/amazon (if I remember I only paid about $70 for PS E3) As PS E4 just came out I'm sure someone has PS E3 for sale. You will then have no problems completing your image resizing.
    2 other questions for you..are you using the Mac side of your intel or Windows?
    if your using the Windows side I can let you have PS 6 (PC) ..freegratus.

  • Help with placing images - why do they appear at 150% and look bad?

    Hi there,
    Relative newbie here.
    I have my display performace in InDesign set to high. Whether I 'place' an image or simply drag it onto the page, and regardless of what image file format I use (tif, png, jpg, whatever), when placed, the images appear about 50% bigger than the source, and low-ish quality. I'm forced then to try to resize them manually so they look good on-screen and when printed.
    Why when I place images do they not appear at 100%?
    Is there a way to resize images other than grabbing the re-size handles and hoping for the best?
    Many thanks.

    OK, if the scale says 100% with the direct select tool, that's what you have. Note that using the regular select tool (the black arrow) will ALWAYS show 100% in the scale fields unless you have set your prefs to "adjust scaling percentage," so that's why you use the direct select tool to check. You can also selct the image with either tool and look at the Info Palette. at 100% the actual and effective ppi listed will be the same. What resolution is currently listed in the Info Palette?
    I asked about click vs, click and drag because in CS4 when you drag a frame it always scales the image to fit. This is not true in CS3.
    Screen captures are typically 72 ppi at the size they are captured. 72 ppi is low for most print work, but for screen captures nobody really  expects much in terms of quality. You really are placing, right, not dragging from Photoshop into ID, which is the equivalent of pasting? Pasting an image gives you only the screen preview in CS3. I'm not sure you'd see a difference with a screen grab, though, since the preview would also be 72 ppi.
    If the image is really too large on the page you can scale in ID by holding the Ctrl + Shift keys while dragging a handle. You must press the keys before clicking the mouse in Windows becasue there is a bug. You can also use the Scale tool, or enter a new scale value in the scaling fields. You can use actual dimensions in those fields if you include the units, by the way.
    In Photoshop you can scale the image using Image > Image Size... If you uncheck the "resample image" box the resolutiuon will change in inverse proportion to the size, so reducing the size will increase the resolution, but there will be no differnce in quality over scaling in ID.

  • Resized images and video seam blurred in motion 4...

    Hello,
    I don't know if my problem is a bug or a stupid mistake I did, or something basic I haven't understood about motion, but here it is:
    I had to edit today a project I created in september 2009 with motion 3. (I installed 2 weeks ago motion 4). The project is made of images and text. When I opened the old project the images looked ok but seamed blurred although the render settings are at best quality.
    I then made an experiment and created a new project in Motion 4 and imported one image, and when I put the quality at best, again this image look unfocused. I would probably not have noticed the problem and thought that the problem comes from the image or from the capabilities of motion, if I didn't have that old video done in motion 3 with the exact same images in the exact same size in perfect crisp quality...
    I did a research in forums, but haven't found any one with a similar problem. People usually have pixelated images because they didn't put the best render quality...
    I then tried to test this on a different computer with motion 4: same problem. I tried all the settings I could find in Motion, but still no result. I trash the preferences, I repaired the permission of my mac, I reinstalled motion 4, tried several images format and size but still no result.
    I noticed that the problem occurs when I resize an image or when I resize a video. At 100% I get perfect quality, but when I resize them, they look blurred. Anything that requires a render seam to be a little blurred when the render quality is set to best. It seams like the anti-aliasing is working so well that it blurs everything... If I put the quality at normal settings, the elements that have been resized look sharp but pixelated...
    I haven't tried to test all this again in motion 3 because I don't have access to any computer that still have that version installed. And I haven't phoned applecare yet because they are closed right now in my country, but I will phone them tomorrow morning and let you know if I get any result with them.
    I really hope I simply forgot something obvious, or maybe there is a new or old setting in motion 4 that I don't know about or haven't understood properly...
    please help me
    Louie
    ps: My version of Motion is French, so I might not use the right english words used in the english version of Motion.

    Thanks for responding.
    I'm of course sizing my picture down. The project I was working on yesterday that helped me notice the problem is 300x300 pixels and the images are around 500x1000 pixels, scaled down to around 20%.
    I haven't notice today that the problem occurs in other project as well. Before I was not looking in detail at the quality, and if no one tells you about it, you won't notice it. But right now all my old projects done in Motion 3, once opened in Motion 4 seam to have that blurry effect on any image or video that is scaled down.
    I understand that Motion might maybe not be very good at scale down things, and might do it less perfetly then Photoshop. But what is odd is that all my old video exported when I had Motion 3 have sharp perfect scaled down images comparred to what I get today in Motion 4.
    The blur I'm speaking about is very light. You won't notice it easily unless you have an old version of the same video to compare it with. But in the project I was working yesterday at 300x300 pixel, the difference was really very obvious, because at this size every detail counts.
    My idea to solve my problem temporarly was to change my Motion project settings to triple its original size (from 300x300 to 900x900) and blow up everthing 300%, export the video at 900x900 and then scale it down through Quicktime instead of Motion at 300x300. This worked and my images are as sharp as they should be. This project is short and light, so I didn't mind doing this conversion, but when I will work with projects that need more render time, it's not a productiv way to work!
    I noticed another odd thing about the problem, I hope I will explain this clearly by describing 3 situations:
    1. I create in Motion 4 a new project with any preset.
    2. I import an image or a video
    3. I scale it down, by pulling one corner (=> the image or video becomes blurred)
    4. In the properties inspector I type the word "100" to get it back to 100%
    => the image is still blurred, it is difficult to see, but when I import again the same image and put it next to it you can see a difference althought both image are at 100%!!!
    or
    1. I create in Motion 4 a new project with any preset.
    2. I import an image or a video
    3. I scale it down, by pulling one corner (=> the image or video becomes blurred)
    4. In the properties inspector I click on the arrow in the top right corner of that reverts to the original settings the image or video
    => the image is perfect
    or
    1. I create in Motion 4 a new project with any preset.
    2. I import an image or a video
    3. I scale it down, by typing any number in the properties inspector (=> the image or video becomes blurred)
    4. In the properties inspector I type the word "100" to get it back to 100%
    => the image is perfect
    So it seams that my problem occurs even at 100% but only if the image has first been modified in its size by pulling one corner and than put back to 100% through the properties inspector...
    hmmmm
    very odd.
    Louie
    Message was edited by: Louie13

  • How to proper resize images and videos at runtime without losing quality?

    Hi guys. I need a bit of help here.
    I've built a flash site in which i want to resize a movie to the stage. I do it by keeping the proportion, thus i only resize the width and then i resize the height acordingly to the new width but keeping the proportion.
    The problem is that my film still looks "pixeled".
    I found a website on which the stage resizes dinamically with the movie and the background images without either of them losing quality. Till now i knew that resizing images or videos in flash at authoring or runtime produces pixeled results.
    This is the website: http://kampanjeweb.apt.no/jotun/romforrom/. Can someone tell me how do they do it without losing quality? just make the browser windowed and resize the margins to see the effect.
    Thanks.

    Hello, Venian.
    About the video, you could try setting the flash.media.Video's smoothing property to TRUE. This should keep a quality, but you can do nothing if the video has a poor quality. You need a great video.
    About the images, you you need to redraw the image each time you resize it. To achieve it, use a combination of Bitmap, BitmapData and Matrix classes. Any doubt, just call again. Here is a simple example:
    var scale:Number = .5;
    var highQualitySourceImage:Bitmap = ...your image...;
    var scaleMatrix:Matrix = new Matrix();
         scaleMatrix.scale(scale, scale);
    var bitmapData:BitmapData = new BitmapData( scale*highQualitySourceImage.width, scale*highQualitySourceImage.height);
         bitmapData.draw(highQualitySourceImage, scaleMatrix);
    var finalBitmap:Bitmap = new Bitmap(bitmapData);
    addChild( finalBitmap );
    Cheers,
    CaioToOn!

  • AppleScript to resize images and save with new name

    I want to make an apple script, which resizes all images of a folder regardless what kind of filetype.
    The source folder will change every day.
    With the script i want to choose a source Folder, resize all images and save the files with my jpeg options in the same folder, but with adding  „_ipad“ in the filename.
    I tried to edit an existing script from this forum, but in Photoshop 5.1 i get the error-message "This function is possibly not available in this Version" in line 18 "save in file newFileName as JPEG with options myOptions"
    How can i save the documents with new name in the existing folder?
    Thanks.
    This is the script i’m working with:
    set inputFolder to choose folder with prompt "Wähle einen Ordner:"
    --set destinationFolder to choose folder with prompt "Wähle einen Zielordner" as string
    tell application "Finder"
              set filesList to (files of entire contents of inputFolder) as alias list
    end tell
    tell application "Adobe Photoshop CS5.1"
              set UserPrefs to properties of settings
              set ruler units of settings to pixel units
              repeat with aFile in filesList
      open aFile showing dialogs never
                        set docRef to the current document
                        tell docRef
                                  set newFileName to my getBaseName(name)
      --resize image height 240 resolution 72 resample method bicubic sharper
      change mode to RGB
      resize image resolution 72
                                  set myOptions to {class:JPEG save options, embed color profile:true, quality:12, format options:progressive, scans:3}
      save in file newFileName as JPEG with options myOptions
                        end tell
      close the current document saving no
              end repeat
              set ruler units of settings to ruler units of UserPrefs
    end tell
    on getBaseName(fName)
              set baseName to fName
              repeat with idx from 1 to (length of fName)
                        if (item idx of fName = ".") then
                                  set baseName to (items 1 thru (idx - 1) of fName) as string
                                  exit repeat
                        end if
              end repeat
              return baseName
    end getBaseName

    This seems like a Photoshop error not an AppleScript one. Have you looked in the Photoshop dictionary to see if the command you are getting the error on exists and if it has those options?
    If all you want to do is resize image files and save the resized image file you might want to look at Automator. Specifically the Scale Image action under Photos.
    regards

  • CrystalReportViewer resizes images and charts

    I've got a nasty bug with CrystalReportViewer that I can't solve.
    When the asp-website shows a report every image (and chart) is resized to about 15x15 pixels (measured with eye). Even toolbar images are resized and it looks kind of nasty. The same problem occurs even if I create a blank webpage (to same project) with just the report I want to show. When I export the report, all images are just fine. I don't have a clue what might affect this crystal report viewer but I hope you have.
    I'm developing with CR 2008 in visual studio 2008. Project is with ASP and c#.
    I've got the same problem with (at least) following:
    - Both Crystal Reports embedded and Crystal Reports 2008.
    - XP and Vista
    - Firefox and IE

    The images and charts vary from about 20x40 (which is streched from side to side as a separator bar) to over 200x200px. One chart is almost as wide as the report. The original size does not affect the result since every chart and image is resized for some reason to that small size. And every chart and picture will show as the same size.
    I tested only with pdf-format because I presume that the problem occurs only in the website. Could something affect the image handler of crystal reports?
    I haven't installed that SP 0 because it is for older version of CR 2008

  • Resizing images and canvas

    Help,
    For gallery sumbmissions, I need to resize my image to 1920 by 1920 pixels. In element 3 it was quite simple, but in elements 10 everything has changed. If I try to chang e the image size, it won't let me chang e the pixels, only the size in inches. Then, moving to the canvass and not changing the image size,when changing the canvass, the original image is cropped and I can't fined anyway to match the image size with the change in canvass.
    thanks.
    Charlie

    Turn on Resample Image and then you can change the pixel size.

  • Automator: Create 3 folders resize images and move .mov files?

    Hi there,
    I am new to automator but would like to learn how to use it.
    On daily basis I get a bunch of pictures and videos in high resolution.
    I would like to automate the following process:
    1. Create 3 folders: HQ, LQ, video
    2. Move the original high resulution .jpeg files to HQ folder
    3. Resize the files to 800x600px (landscape) or 600x800px (portrait) and save them in LQ
    4. Move the .mov video files into video folder
    5. Rename all JPEG files in LQ to a value that I can enter at this time (for example I type "3 bedroom apartment munich" and it will rename it to "3 bedroom apartment munich-1.jpg, ...-2.jpg, ...3.jpg, ...)
    Is this even possible with automator or do I have to use additional tools like "A Better Finder Rename 9"?
    Looking forward for some input to get started. Thanks for all who help me to get my daily job done much faster.
    Cheers,
    Chris

    You can start with this workflow. Download it (below) so you can see how it works. This is a workflow to handle the HQ and LQ options. On the video, that would be a separate workflow but easier -- you would just not combine it with this process.
    Let me know what you think and if we need to tweak it, then post back.
    Here is the workflow for you to download

  • Resize Images and landscape them

    I need to resize thousands of MultiPage PDFs and make sure they are landscape
    I want to resize to 8x11 landscape...
    can I do this in a batch mode...I have way to many to do this on a one by one basis.
    I have Adobe Acronat Pro Version 10.0.0

    I can resize the image but i dont see a batch option....
    NOTING: my main reason is to decrease the file size...simply reducing hte image size does not accomplish this.  Using a printer driver does....so I am not really getting what I need.
    I need to decrease file size....if this works better by decreaseing the file size as well as resoultion then great...
    If I pipe through a driver I get 50% reduction and still good quality....
    I used the sfotware and can only Reduce the file size in one by one process...not batch...and doign so does nto decrease file size....If I could do this in a batch and then resample the image this will sig decrease the size....but I need to do this ALL in BATCH MODE....I have 40,000 images....

  • Resizing images and iPhoto crashes

    Okay I have two questions/problems
    1) I understand that if you crop an image it reduces the size (kb) but sometimes I need the size of a photo significantly reduced (for 100-300 kb limits uploading to websites) Is there a way to just reduce the size (kb wise) without cropping out almost all of your picture?
    2) My iPhoto gets hung up very easily. I see this mostly after I Duplicate a photo or import photos. Everything works fine but then when i go to click on another pic or something I get the spinning icon and it gets hung up and I have to force quit it. Any suggestions??

    JPG is a compressed format. It becomes compressed when saved. It is a different matter while you have the file open. The "29MB" size is an approximation of the image's uncompressed size while working in Photoshop.

  • How to disable resizing images and tables in designMode?

    In own wysiwyg editor this function must be disabled. How make it disabled?

    A good place to ask advice about web development is at the MozillaZine "Web Development/Standards Evangelism" forum.
    *http://forums.mozillazine.org/viewforum.php?f=25
    The helpers at that forum are more knowledgeable about web development issues.<br>
    You need to register at the MozillaZine forum site in order to post at that forum.

  • Resize image code doesn't work for some JPGs

    Hi. I'm using the below code to resize images and store them on the server. However, with some JPGs, the resize produces a reddish tint on the image. Any ideas what could be causing this? Here's the original image: http://www.unctv.org/tWxkBbq_10M6wKRRL/PNCWWD01.jpg and here's what it produces afterward: http://www.unctv.org/tWxkBbq_10M6wKRRL/PABDFC01__1289231445291.jpg
    Photoshop CS5 is used to produce the JPG input for this app. Thanks.
    public BufferedImage resizeVeryHigh(InputStream inputStream, File resizedFile) throws IOException {
      BufferedImage bufferedImage = null;
      try {
          Image newImage = ImageIO.read(inputStream);
          int newWidth = (int)this.targetWidth;
          ImageIcon imageIcon = new ImageIcon(newImage);
          Image image = imageIcon.getImage();
          Image resizedImage = null;
          int iWidth = image.getWidth(null);
          int iHeight = image.getHeight(null);
          // This code ensures that all the pixels in the image are loaded.
          Image temp = new ImageIcon(resizedImage).getImage();
          // Create the buffered image.
          bufferedImage = new BufferedImage(temp.getWidth(null), temp.getHeight(null), BufferedImage.TYPE_INT_RGB);
          // Copy image to buffered image.
          Graphics g = bufferedImage.createGraphics();
          // Clear background and paint the image.
          g.setColor(Color.white);
          g.fillRect(0, 0, temp.getWidth(null), temp.getHeight(null));
          g.drawImage(temp, 0, 0, null);
          g.dispose();
          // Encodes image as a JPEG data stream
          FileOutputStream out = new FileOutputStream(resizedFile);
          JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
          JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bufferedImage);
          param.setQuality(1.0f, true);
          encoder.setJPEGEncodeParam(param);
          encoder.encode(bufferedImage);
      catch (Exception e) {
            this.error = e.getMessage();
          return bufferedImage;
    }Edited by: oneworld95 on Nov 8, 2010 11:34 AM

    I don't know anything about the jpeg encoders, but I do see code that doesn't make any sense to me:
    Image resizedImage = null;
    int iWidth = image.getWidth(null);
    int iHeight = image.getHeight(null);
    // This code ensures that all the pixels in the image are loaded.
    Image temp = new ImageIcon(resizedImage).getImage();What is the point of creating an ImageIcon from a null image?
    int newWidth = (int)this.targetWidth;I don't see where you actually use this variable, so how does the image get resized?
    For more help create a [url http://sscce.org]SSCCE, that demonstrates the incorrect behaviour and maybe someone will take a look at it.

  • Upload image and make thumbnail

    Is that possible for ADDT to upload and resize image and make a thumbnail at the same time?

    Hi chan15,
    that´s only possible with a Custom Trigger which contains custom PHP code to create a thumbnail from the uploaded image and store it in whatever folder.
    Cheers,
    Günter Schenk
    Adobe Community Expert, Dreamweaver

  • Fonts looking bad after upload

    Hi,
    I have used a special font, by that I mean a font which will not be found on most computers. Now within some elements, such as a some buttons, a few graphics, the font appears perfectly. When I check on other PC's the font is not what I had selected. Also, the font, when I run the movie through Flash CS4, appears perfect, but once I upload it, the font is not smooth and looks bad. I read up a little about embedding characters, and even tried the option which comes in the text box properties, but nothing seems to help. I don't think I grasped the concept well. Can anyone please explain how I can get my font to appear and look good on all PCs??
    Thanks,
    Aditi

    Is this all dynamic text or is it text that is manually written in to the file at authoring time such that it could be static text?  If it is static text but you are using dynamic textfields, then try switching them to be static textfields.  If it is already static textfields, then you could try breaking the textfields down to being raw graphics (select the textfield, then choose Modify -> Break Apart, Modify -> Break Apart)
    If they must be dynamic textfields, and using the embed option in the properties panel isn't working, then try embedding the font in the library and use it from there... To do that...  in the library in the upper right is a small menu where you can select "New Font"... choose that and select the font you want from the list.  Then you can assign that embedded font as you normally would, but you need to find the name it has in the library and in trhe font selection it will have an asterisk next to it.  So if the Font is named "Font 1" in the library, then in the font selection in the properties panel it will appear as "Font 1* "

Maybe you are looking for

  • Adding one day to a month

    Hi, I would like to add one day to a date. It seems like such a simple thing yet I have only found how to add a day to sysdate (or to add months to a given date). Any help? Thanks. Leah

  • Can i configure a network with ACS and ISE?

    I have both acs and ise, how do i integrate these appliance to work togheter? Thanks

  • Don't have permissions to data drives after replacing system drive

    In my 10.4 Mac Pro, the hard drive with the OS died.  I have two more hard drives in there that I store all my data on, those are fine.  I bought a new drive, reloaded OSX, created a administrator account during setup, but now I don't appear to have

  • Calling paintComponent(Graphics g) in another class

    Dear Friends, I have a class (Class Pee) where I implemented the paintComponent(Graphics g) and another class (Class Bee) where I generate some datas. My intention is to call the paintComponent(Graphics g) method in class Pee at class Bee to make use

  • Searching for material with material group

    Hi Friends, How to get the old material no. material no., description after searching for material with material group.please reply....