<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Java image resizer servlet</title>
	<atom:link href="http://greatwebguy.com/programming/java/java-image-resizer-servlet/feed/" rel="self" type="application/rss+xml" />
	<link>http://greatwebguy.com/programming/java/java-image-resizer-servlet/</link>
	<description>Self-proclaimed greatness is a hard thing to prove.</description>
	<lastBuildDate>Mon, 01 Mar 2010 19:05:10 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Dariel PG</title>
		<link>http://greatwebguy.com/programming/java/java-image-resizer-servlet/comment-page-1/#comment-1205</link>
		<dc:creator>Dariel PG</dc:creator>
		<pubDate>Wed, 27 Jan 2010 20:16:51 +0000</pubDate>
		<guid isPermaLink="false">http://greatwebguy.com/programming/java/java-image-resizer-servlet/#comment-1205</guid>
		<description>Hi everyone!!

How can I pass more than one parameter to a servlet??
I&#039;m using JDeveloper, and I need to pass several parameters to an image component, wich load de image from data base using a servlet.

If can any one helme I will apreciate. Thanks</description>
		<content:encoded><![CDATA[<p>Hi everyone!!</p>
<p>How can I pass more than one parameter to a servlet??<br />
I&#8217;m using JDeveloper, and I need to pass several parameters to an image component, wich load de image from data base using a servlet.</p>
<p>If can any one helme I will apreciate. Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kirun</title>
		<link>http://greatwebguy.com/programming/java/java-image-resizer-servlet/comment-page-1/#comment-1193</link>
		<dc:creator>Kirun</dc:creator>
		<pubDate>Thu, 07 Jan 2010 15:19:32 +0000</pubDate>
		<guid isPermaLink="false">http://greatwebguy.com/programming/java/java-image-resizer-servlet/#comment-1193</guid>
		<description>Hi WebGuy,

I got it to work that day itself. Thank you for that. 

I changed the way i was invoking the servlet. 

First i used this way, it did not work.

  

Below worked for me.

 

But i did not understand why the earlier code did not work.

Another one query, i have is, the resizing of image is reducing the quality of image a lot. Is there anyway we can make not to degrade the quality so much. 

Thank you for the code, it was helpful.</description>
		<content:encoded><![CDATA[<p>Hi WebGuy,</p>
<p>I got it to work that day itself. Thank you for that. </p>
<p>I changed the way i was invoking the servlet. </p>
<p>First i used this way, it did not work.</p>
<p>Below worked for me.</p>
<p>But i did not understand why the earlier code did not work.</p>
<p>Another one query, i have is, the resizing of image is reducing the quality of image a lot. Is there anyway we can make not to degrade the quality so much. </p>
<p>Thank you for the code, it was helpful.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: webguy</title>
		<link>http://greatwebguy.com/programming/java/java-image-resizer-servlet/comment-page-1/#comment-1191</link>
		<dc:creator>webguy</dc:creator>
		<pubDate>Tue, 05 Jan 2010 17:43:09 +0000</pubDate>
		<guid isPermaLink="false">http://greatwebguy.com/programming/java/java-image-resizer-servlet/#comment-1191</guid>
		<description>Are you running in a Linux or Windows environment?   What exactly did you include in the src attribute of the img tag?</description>
		<content:encoded><![CDATA[<p>Are you running in a Linux or Windows environment?   What exactly did you include in the src attribute of the img tag?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kirun</title>
		<link>http://greatwebguy.com/programming/java/java-image-resizer-servlet/comment-page-1/#comment-1190</link>
		<dc:creator>Kirun</dc:creator>
		<pubDate>Tue, 05 Jan 2010 17:04:01 +0000</pubDate>
		<guid isPermaLink="false">http://greatwebguy.com/programming/java/java-image-resizer-servlet/#comment-1190</guid>
		<description>Thank you for fast response.

Yes, my servlet is setup correctly. Using Netbeans IDE to develop, i have created simple java web application project in it to test this sevlet.




   
        image
        SERVLET.ImageResizer
        1
   
   
    
        image
        /image
    
   
    
        
            30
        
    
    
        index.jsp
    
    

yes web application is set to run in root context. I have just changed the folder names to different. like /Albums refers to /Images i have changed in the servlet code and even while calling.

I think its not invoking Servlet from img tag. I have JDK 1.6 and Tomcat 6.

Your feedback will be help ful.</description>
		<content:encoded><![CDATA[<p>Thank you for fast response.</p>
<p>Yes, my servlet is setup correctly. Using Netbeans IDE to develop, i have created simple java web application project in it to test this sevlet.</p>
<p>        image<br />
        SERVLET.ImageResizer<br />
        1</p>
<p>        image<br />
        /image</p>
<p>            30</p>
<p>        index.jsp</p>
<p>yes web application is set to run in root context. I have just changed the folder names to different. like /Albums refers to /Images i have changed in the servlet code and even while calling.</p>
<p>I think its not invoking Servlet from img tag. I have JDK 1.6 and Tomcat 6.</p>
<p>Your feedback will be help ful.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: webguy</title>
		<link>http://greatwebguy.com/programming/java/java-image-resizer-servlet/comment-page-1/#comment-1189</link>
		<dc:creator>webguy</dc:creator>
		<pubDate>Tue, 05 Jan 2010 16:09:42 +0000</pubDate>
		<guid isPermaLink="false">http://greatwebguy.com/programming/java/java-image-resizer-servlet/#comment-1189</guid>
		<description>It&#039;s a little difficult to debug without any details.  Is your servlet set up correctly, did you include the appropriate querystring parameters after /image?  Is your webapp setup to run at a root context?  There are some details that aren&#039;t included in this article, like the rest of the web.xml.</description>
		<content:encoded><![CDATA[<p>It&#8217;s a little difficult to debug without any details.  Is your servlet set up correctly, did you include the appropriate querystring parameters after /image?  Is your webapp setup to run at a root context?  There are some details that aren&#8217;t included in this article, like the rest of the web.xml.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kirun</title>
		<link>http://greatwebguy.com/programming/java/java-image-resizer-servlet/comment-page-1/#comment-1188</link>
		<dc:creator>Kirun</dc:creator>
		<pubDate>Tue, 05 Jan 2010 16:02:01 +0000</pubDate>
		<guid isPermaLink="false">http://greatwebguy.com/programming/java/java-image-resizer-servlet/#comment-1188</guid>
		<description>Hai 

I was looking some code like this itself for resizing images on load. But its not wokring for me, it does not show any error, it loads up but does not show image.

I have checked most of the things, its good. But when i went to view source from firefox and clicked the src of the image, it gave below error.

&quot;The requested resource (/image) is not available.&quot;

Waiting for the replies.

Thank you.
Kirun</description>
		<content:encoded><![CDATA[<p>Hai </p>
<p>I was looking some code like this itself for resizing images on load. But its not wokring for me, it does not show any error, it loads up but does not show image.</p>
<p>I have checked most of the things, its good. But when i went to view source from firefox and clicked the src of the image, it gave below error.</p>
<p>&#8220;The requested resource (/image) is not available.&#8221;</p>
<p>Waiting for the replies.</p>
<p>Thank you.<br />
Kirun</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yevhenia</title>
		<link>http://greatwebguy.com/programming/java/java-image-resizer-servlet/comment-page-1/#comment-1123</link>
		<dc:creator>Yevhenia</dc:creator>
		<pubDate>Tue, 01 Sep 2009 15:39:06 +0000</pubDate>
		<guid isPermaLink="false">http://greatwebguy.com/programming/java/java-image-resizer-servlet/#comment-1123</guid>
		<description>Thanks, its working! Will use on my website.</description>
		<content:encoded><![CDATA[<p>Thanks, its working! Will use on my website.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://greatwebguy.com/programming/java/java-image-resizer-servlet/comment-page-1/#comment-1104</link>
		<dc:creator>James</dc:creator>
		<pubDate>Tue, 14 Jul 2009 01:58:34 +0000</pubDate>
		<guid isPermaLink="false">http://greatwebguy.com/programming/java/java-image-resizer-servlet/#comment-1104</guid>
		<description>Thanks!  I was looking for this.  I&#039;ll need to modify it so that the default dimensions is just the original image&#039;s default dimensions.  This code is great for java/servlet based mobile WAP sites.  But yeah, echo&#039;ing the previous comments... this code is easy to follow.</description>
		<content:encoded><![CDATA[<p>Thanks!  I was looking for this.  I&#8217;ll need to modify it so that the default dimensions is just the original image&#8217;s default dimensions.  This code is great for java/servlet based mobile WAP sites.  But yeah, echo&#8217;ing the previous comments&#8230; this code is easy to follow.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aaron Bailey</title>
		<link>http://greatwebguy.com/programming/java/java-image-resizer-servlet/comment-page-1/#comment-955</link>
		<dc:creator>Aaron Bailey</dc:creator>
		<pubDate>Wed, 04 Mar 2009 19:37:38 +0000</pubDate>
		<guid isPermaLink="false">http://greatwebguy.com/programming/java/java-image-resizer-servlet/#comment-955</guid>
		<description>Hoping someone has some thoughts on this. I have code below that is manipulating the image size similarly. We have upgraded java from JDK1.4.2_13 to JDK1.6.0_10. I am getting this error, but what is weird, is this same code worked fine under 1.4.2. I find that if I set a break point in the scaleImage method at the line where resizedImage is created (Image resizedImage = Toolkit.getDefaultToolkit()....) and let 30-45 seconds go by before resuming, everything works fine. If I let it run with no break points, this line:

BufferedImage bufferedImage = new BufferedImage(image.getWidth(null), image.getHeight(null),BufferedImage.TYPE_INT_RGB);

...fails because image.getWidth(null) and getHeight(null) are returning -1. Did anything change in JDK 1.6?

Thanks for any input!

Here is the stack trace:

java.lang.IllegalArgumentException: Width (-1) and height (-1) cannot be &lt;= 0
        at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:999)
        at java.awt.image.BufferedImage.(BufferedImage.java:312)
        at strata.ws.ImageImportServlet.toBufferedImage(Unknown Source)
        at strata.ws.ImageImportServlet.scaleImage(Unknown Source)
        at strata.ws.ImageImportServlet.processRequest(Unknown Source)
        at strata.ws.ImageImportServlet.doPost(Unknown Source)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)

{code}private BufferedImage scaleImage(Image sourceImage, int width, int height)
{
ImageFilter filter = new ReplicateScaleFilter(width,height);
ImageProducer producer = new FilteredImageSource
(sourceImage.getSource(),filter);
Image resizedImage = Toolkit.getDefaultToolkit().createImage(producer);

return this.toBufferedImage(resizedImage);
}

private BufferedImage toBufferedImage(Image image)
{
image = new ImageIcon(image).getImage();
BufferedImage bufferedImage = new BufferedImage(image.getWidth(null), image.getHeight(null),BufferedImage.TYPE_INT_RGB);
Graphics g = bufferedImage.createGraphics();
g.setColor(Color.white);
g.fillRect(0,0,image.getWidth(null),image.getHeight(null));
g.drawImage(image,0,0,null);
g.dispose();

return bufferedImage;
}{code}</description>
		<content:encoded><![CDATA[<p>Hoping someone has some thoughts on this. I have code below that is manipulating the image size similarly. We have upgraded java from JDK1.4.2_13 to JDK1.6.0_10. I am getting this error, but what is weird, is this same code worked fine under 1.4.2. I find that if I set a break point in the scaleImage method at the line where resizedImage is created (Image resizedImage = Toolkit.getDefaultToolkit()&#8230;.) and let 30-45 seconds go by before resuming, everything works fine. If I let it run with no break points, this line:</p>
<p>BufferedImage bufferedImage = new BufferedImage(image.getWidth(null), image.getHeight(null),BufferedImage.TYPE_INT_RGB);</p>
<p>&#8230;fails because image.getWidth(null) and getHeight(null) are returning -1. Did anything change in JDK 1.6?</p>
<p>Thanks for any input!</p>
<p>Here is the stack trace:</p>
<p>java.lang.IllegalArgumentException: Width (-1) and height (-1) cannot be &lt;= 0<br />
        at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:999)<br />
        at java.awt.image.BufferedImage.(BufferedImage.java:312)<br />
        at strata.ws.ImageImportServlet.toBufferedImage(Unknown Source)<br />
        at strata.ws.ImageImportServlet.scaleImage(Unknown Source)<br />
        at strata.ws.ImageImportServlet.processRequest(Unknown Source)<br />
        at strata.ws.ImageImportServlet.doPost(Unknown Source)<br />
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)<br />
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)<br />
        at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)</p>
<p>{code}private BufferedImage scaleImage(Image sourceImage, int width, int height)<br />
{<br />
ImageFilter filter = new ReplicateScaleFilter(width,height);<br />
ImageProducer producer = new FilteredImageSource<br />
(sourceImage.getSource(),filter);<br />
Image resizedImage = Toolkit.getDefaultToolkit().createImage(producer);</p>
<p>return this.toBufferedImage(resizedImage);<br />
}</p>
<p>private BufferedImage toBufferedImage(Image image)<br />
{<br />
image = new ImageIcon(image).getImage();<br />
BufferedImage bufferedImage = new BufferedImage(image.getWidth(null), image.getHeight(null),BufferedImage.TYPE_INT_RGB);<br />
Graphics g = bufferedImage.createGraphics();<br />
g.setColor(Color.white);<br />
g.fillRect(0,0,image.getWidth(null),image.getHeight(null));<br />
g.drawImage(image,0,0,null);<br />
g.dispose();</p>
<p>return bufferedImage;<br />
}{code}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ray</title>
		<link>http://greatwebguy.com/programming/java/java-image-resizer-servlet/comment-page-1/#comment-947</link>
		<dc:creator>ray</dc:creator>
		<pubDate>Fri, 06 Feb 2009 16:39:58 +0000</pubDate>
		<guid isPermaLink="false">http://greatwebguy.com/programming/java/java-image-resizer-servlet/#comment-947</guid>
		<description>Hi webguy 

I am looking for a way to get the pics uploaded before they hit the browser in the for of an application attached to my site. Once this happens it can then be sent to the browser and into the server as its the slow browser thats hurting me as internet speed of clients is quite low.

Is there an application that can be modified.</description>
		<content:encoded><![CDATA[<p>Hi webguy </p>
<p>I am looking for a way to get the pics uploaded before they hit the browser in the for of an application attached to my site. Once this happens it can then be sent to the browser and into the server as its the slow browser thats hurting me as internet speed of clients is quite low.</p>
<p>Is there an application that can be modified.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
