Resizing an image without AWT

Hello, here is my question:
I have seen many examples on the Web explaining how to resize an image in Java. All of them use AWT. The problem is, my application is web-based, hosted on a server without X11 installed. Now, I know from the Java2D FAQ that from Java 1.4, you should be able to bypass this problem by setting this system property: "-Djava.awt.headless=true". But unfortunately, I don't have access to the system properties either. My website is hosted by a company sharing it's servers between many customers, and therefore, I cannot customize the Caucho Resin server to fit my needs.
So I'm wondering if there's any other way to resize an image in a web application with Java.
Thank you in advance!

Unfortunately, it does not seem to work... I'm still getting an "Exception Class:      class java.lang.NoClassDefFoundError" error as soon as I try to use the "getGraphics" method on the webhost's server. It works on my local machine, thought. Here's the trace I'm getting:
java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Class.java:140)
java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:62)
java.awt.image.BufferedImage.createGraphics(BufferedImage.java:1041)
java.awt.image.BufferedImage.getGraphics(BufferedImage.java:1031)
myApp.servlet.CommonFunctions.createResizedCopy(CommonFunctions.java:202)
myApp.servlet.CommonFunctions.normalizeImage(CommonFunctions.java:107)
itemProcess_jsp._jspService(_itemProcess__jsp.java:166)
com.caucho.jsp.JavaPage.service(JavaPage.java:75)
com.caucho.jsp.Page.subservice(Page.java:485)
com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182)
com.caucho.server.http.Invocation.service(Invocation.java:312)
com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
com.caucho.server.http.RunnerRequest.handleRequest(RunnerRequest.java:342)
com.caucho.server.http.RunnerRequest.handleConnection(RunnerRequest.java:272)
com.caucho.server.TcpConnection.run(TcpConnection.java:137)
java.lang.Thread.run(Thread.java:536)
Thanks again in advance for the help!

Similar Messages

  • Help - Resizing images WITHOUT awt or graphics2D

    Hi all.
    I have a JSP application running on a shared Tomcat hosting.
    My users can send images to the site.
    I cannot find a way to resize an image without using AWT or graphics.
    (I also cannot switch to headless mode, the JVM is not mine to control)
    I tried using ImageIO but crashed because there is no X11 graphics on the server.
    I tried using the PJA toolkit, but I could not find a way to RESIZE an image using PJA.
    Help ! This is driving me mad.
    Thanks !
    Shachar Weis.

    Jeff,
    The printing service should only need to know the size at which you want it printed. At that point they can adjust the PPI to a number that will shrink the print size, but not destroy any pixels.
    You can adjust the DPI as you Export if you wish, but that should not be necessary. To change the DPI, choose JPEG Original, say, and click on Edit and you can change the DPI to a higher number, and export.
    If you export any photo, open it in Preview, click on Tools and choose Adjust size then you can see the impact of changing the Resolution on inches/or metric measure, which is what the printer can do. In Adjust Size be sure to Deselect the option to Resample -- the latter would otherwise remove pixels and result in a lower resolution.
    Ernie

  • Creating Thumbnails of Images without AWT

    I've searched in a lot of places, and am becoming increasingly surprised I cannot find a straightforward answer to a problem I have. I run Tomcat on a server which has no X11, and I do not want to install it. However, I am also trying to create a servlet which will take an image from a byte array and create a thumbnail of it.
    While I have seen many examples of this, all use AWT, which seems to require using X11 or some windowing system even to run at all (despite my not trying to create a window or anything). While I understand that there is an option that can be added to the initialization script for Tomcat ("JAVA_OPTS=-Djava.awt.headless=true") I would far prefer simple code that didn't use AWT at all.
    Does anyone know how to create a thumbnail or resize an image without the use of the AWT library whatsoever? Thanks very much!

    Hmm... sorry I didn't know that.
    I remember seeing some section on this website about Java Imaging or something like that and it seemed totally independent of AWT.
    I came accross another imaging article:
    http://johnbokma.com/java/obtaining-image-metadata.html , this one doesn't seem to use AWT - at least I don't see any in the imports.
    May be Images are supposed to work only with AWT.
    Here's another set of examples:
    http://www.exampledepot.com/egs/javax.imageio/pkg.html
    that demonstrates the javax.imageio package, but those examples also use AWT.
    I think one could re-size an image on a website to create thumbnails, by specifying a percent width and height. and may be there's no need to have a package to create thumbnails on a web page when it could be done with HTML and that's probably why there isn't image processing for web pages (this is just my guess work, I could be wrong)
    Message was edited by:
    appy77

  • How can I resize an image without losing resolution or using the crop tool? I am using Photoshop Elements 13 on a PC.

    How can I resize an image without losing resolution or using the crop tool? I am using Photoshop Elements 13 on a PC.

    Hi Peru Bob,
    I've tried two images, the results were:
    Image 1
    Jpg, original file size 923KB, dimensions 848px x 279px.
    After resizing to 848px x 180px with 72dpi, the file size decreased to 164KB.
    Image 2
    Jpg, original file size 809KB, dimensions 1200px x 1800px.
    After resizing to 668px x 722px with 72dpi, the file size decreased to 307KB.
    So, there seems to be a fair file size loss - is this to be expected?

  • Resize A Image Without Losing Quality

    I have been reading about how to best resize image in PS CS4/CS5.  I've read that you should increase the size of a image in increments and I’ve also read that you should resize using the bicubic smoother setting in PS.
    The image that I would like to resize is 5W x 7H and resolution of 150. I would like to print this image at 30W x 40H on a HP Designjet 5500ps.
    Any recommendation on how I should go about resizing the image without losing quality?

    No matter which method you used, scaling up a photo 5 times is going to look very good.
    There are some software that purports to scale up an image without blurry edges. Not sure how well they work.
    If you can obtain the original image and rescan it at a higher resolution that would work better.
    Or, if the photo can be easily recreated as a vector drawing, then do that with illustrator and print it out large.
    Or if you or someone you know is a great artist, then scale up the photo in photoshop (which would become blurry), then hand correct the edges to make them sharp. This requires drawing ability.

  • RESIZING GIF IMAGES WITHOUT LOSING ANIMATION

    Is it possible to resize a Gif image without losing animation?  I tried but unfortunately lost the animation. I use CS3 Extended.  Thanks

    No, I don't think so. for that, you'd probably have to import your animation using the Video to Layers option, resize, then rebuild the animation and export it.
    Mylenium

  • How do I resize an image without stretching it?

    I have an image of approx. 1000x1000px...  I need to make the image 500x200.  Everytime I try to resize the image it comes out looking "stretched".  Is there any way of resizing or shrinking the image in photoshop without distorting the image?
    Thanks!

    Going from a 1:1 square aspect ratio to a 5:2 aspect ratio is quite a change in aspect ratio with out distortion at all you would need to crop off 60% the image or add canvas.  If you look at it this way you get a better understanding
    Downsize the image from 1000x1000px to 500x500px and there will be no distortion now cut that image into two peices one 500x200 pixels leave 500x300 its a 40% 60% split
    The other way is Downsize the image from 1000x1000px to 200x200px  there will be no distortion now add canvas to make the image 500x200pxb you will have what you want no distortion your whole image with a 300x200 side border

  • How to resize photoshop image without changing canvas size?

    When i had the older versions of photoshop i would change the image size and it would enlarge on my canvas for me to rearrange. Lately i realized on CC when i increase image size so does my canvas size. Is there anyway to prevent my canvas size from increasing too?

    I am having what appears to be this same issue.    I am using PS CC.  
    hello @ c.pfaffenbichler
    I resized my image in image> image size.  
    Details:
    I am not a ps expert but woefully self taught.  However through much trial and error I have in my experience over the years, achieved some comfortability with the image size dialog box as well as the canvas size dialog box.  SOME comfortability lol.  That is, I feel that I understand what is going on most of the time and when flummoxed have studied adobe literature or read hundreds of posts here and elsewhere to gain additional knowledge which many times resolves the issue.  I like digging and finding the answers.
    In this case, my digging is done dug a giant hole and I am exhausted and found nuthin'.
    I feel like I am going nutso.
    In my mind,
    1.  There is the image I am working on
    2.  There is the canvas the image is sitting on
    My expectation and previous experience is that I can change the Image size by going to Image > image size and this change does not affect the canvas size.
    My expectation and previous experience is that I can go to Image >canvas size and change the canvas size and this does not affect the image size.
    I could also use the Transform to resize the image which also, would not in my expectation, change the canvas size.
    In the beginning of my workflow on this particular collage I did not have this issue,  so that leads me to believe I did or am doing something to cause this rather than it being some kind of bug.    But what do I know.
    I thank you in advance for your assistance.

  • How to resize large images without losing quality

    Hello I have an image that I am trying to use as an email. Right now it is 2108 pixels. And for an email it should be 600 px. I created this image in illustrator as vectors and type.
    Whenever I go into image size and i change it to be 600 pixels it gets extremely blurry. I have also tried converting this to a smart object... doesnt work. How do I resize my large image to be smaller without losing quality???

    here is an example sceenshot of the opening dialog (.ai opened directly in Photoshop)
    your illustrator vector should be rastered sharp at 100% actual Pixels in Photoshop
    that is where you want to evaluate sharpness in Photoshop...
    then File> Save for Web & Devices (and drag that saved file icon into an open web browser)
    still no joy, embed your saved image here using the forum's camera icon...

  • How do i resize an image without distorting it?

    I used the lasso tool on an image and want to place it on a background image but resize it and make it smaller, however when I do it distorts the image and makes it highly pixelated

    Try holding down Shift while resizing; this will constrain proportions.
    If you're making it smaller, not much should happen quality-wise. Generally speaking, resizing down is almost always better than resizing up. Did you commit the change (like pressing Enter or clicking the commit/checkmark icon in the Options panel)? It always looks a little pixelated until you commit.

  • How to resize an image without squashing it?

    I am trying to add image to mug template ,so when I resize it get squashed how I resolve this
    thanks

    Hold the shift key down while resizing, and check that the percentages are the same in the top bar. (The numbers on the far right in these screen shots)
    It doesn't matter what the numbers are, as long as they match each other.
    WRONG:
    CORRECT:

  • Resize created image?

    I've created an image from scratch using Photoshop CS2 (I combined a number of images into one image), to discover I need to make the image larger. Do I need to start over, or is there a way to resize the image without degrading the quality of the image?
    Thanks

    The images I started with were large, but I imported them into a project that had a 3" x 3" size. I just discovered I need the final image to be larger, 6" x 6". Is this possible without degrading the quality of the work?
    I need it for print. I'm designing an image a friend is turning into a badge. I found out a min ago the larger the image the better the result.
    Thx

  • Resizing images without export

    Hi all,
    I would like to create a folder that contains re-sized versions of my master images. The folder will be photos that I am posting to my web site and I want to be able to control their size and keep this resized image in my aperture library. I am uploading them through the site host's uploader (squarespace) using finder, not exporting through aperture. Is there a way to create duplicate,resized versions of the images without exporting and re-importing the photos?
    I know that aperture isn't photo editing software, but i expected that it would be able to do basic things (mirror, resize, etc) and am constantly disappointed. I could round-trip to photoshop, but I hope there's an easier solution.
    Thanks,
    John

    First question - why do you need the JPEGs? If it's to upload them to a site via FTP there are export plug-ins to do this directly from within Aperture.
    Using the media browser isn't going to help you at all because that will be accessing Previews in Adobe98 profile - not something you should be putting up on a website.
    I also came across this problem when I wanted to convert a large number of raw files to jpegs and keep the new jpegs in my library. At the time I was running low on disk space and didn't need the raws anymore, but had to go through the process of exporting and re-importing for a bunch of projects.
    Sorry, but that's a bit too alien an idea for me - I never threw away negatives back when I was using film, why would you throw away RAW files now?
    Another pet peeve I have is that there is no status indicator when exporting (2 minutes left, 25% done, etc....anything besides a beachball), so I don't know how long the export will take, and on my 2006 macbook it sometimes takes a while.
    At the bottom of the Browser pane on the left you will see a progress 'swirl' when exporting, importing or generating Previews. Click on it to bring up the activity window with progress bars for all current actions. You can also access it through Window>Show Activity.
    Ian

  • Resizing image without cropping

    I am trying to add a value to the width in InDesign in order to resize an image. What's happening is that it is resizing the image by cropping it. I don't want the image cropped; I just want it reduced proportionately. What should I do?

    Answered in your other thread.

  • Using Javascript & Actions to resize an image and add the filename as text

    Hello,
    I am currently working on a way to take an image, resize it and add exactly what is in it's file name (before extension) as a text layer. I have succeded in this BUT am having issues with file names that require more than one line of text.
    I need the text to align to the bottom of the image & the script or action must then resize the image so that the text does not overlap.
    Any ideas on how this can be done?
    At the moment I am using:
    -"Fit Image.jsx" to resize my image to a specific size (This was included in the Photoshop CS5 scripts)
    - A script to add the file name without extension and place the file name at a specific position.
    AdFileName.jsx
    if ( documents.length > 0 )
    var originalRulerUnits = preferences.rulerUnits;
    preferences.rulerUnits = Units.PIXELS;
    try
      var docRef = activeDocument;
      // Now create a text layer at the front
      var myLayerRef = docRef.artLayers.add();
      myLayerRef.kind = LayerKind.TEXT;
      myLayerRef.name = "Filename";
      var myTextRef = myLayerRef.textItem;
      // strip the extension off
      var fileNameNoExtension = docRef.name;
      fileNameNoExtension = fileNameNoExtension.split( "." );
      if ( fileNameNoExtension.length > 1 ) {
       fileNameNoExtension.length--;
      fileNameNoExtension = fileNameNoExtension.join(".");
      myTextRef.contents = fileNameNoExtension;
      // off set the text to be in the middle
      myTextRef.position = new Array( docRef.width / 2, docRef.height / 2 );
      myTextRef.size = 12;
            myTextRef.font="Arial-BoldMT"
            //set position of text
            myTextRef.justification = Justification.CENTER;
            myTextRef.kind = TextType.PARAGRAPHTEXT;
            myTextRef.width= docRef.width;
            myTextRef.height= docRef.height/ 2;
            myTextRef.position= [0, docRef.height * 0.88];
    catch( e )
      // An error occurred. Restore ruler units, then propagate the error back
      // to the user
      preferences.rulerUnits = originalRulerUnits;
      throw e;
    // Everything went Ok. Restore ruler units
    preferences.rulerUnits = originalRulerUnits;
    else
    alert( "You must have a document open to add the filename!" );
    Can the position be changed to allow more rows of text but keep it aligned with the bottom of the layer?
    How can I script in a way to make the image resize based on the amount of text lines?
    Any help would be greatly appreciated.

    You can add a text layer any where the only thing you need to worry about is the size of the font you use.  You can normally calculate a font size by saving the images resoltuion and then setting its resolution to 72 DPI calculate a font size basied of the images pixel width and the number of characters you want in a line. After adding the text layer you can restore the image to its original resolution and align the text layer by making a selection and alignint the text layer to the selection.  There are nine posibilites like the positions in the selection you can align to like a tick tack toe board. You need to use a script to add the text layer because your retrieving the filename.  The positioning of the text layer could be done easily in an action the would use the scriot to add a text layer the do a select all  the align the added text layer to the selection.
    About your script don't make text paragraph just add new line characters to make a multi line text layer So it can be positioned easily
    I do just that with my stampexif action.  The action uses my stampexif Photoshop java script to add a multi line text layer containing some formatted EXIF data then the action centers the text layer and add a layer style to it. Link http://www.mouseprints.net/old/dpr/StampExif.jsx Example

Maybe you are looking for