Index: utils/josm/plugins/ywms/src/org/openstreetmap/josm/plugins/ywms/ImageLoader.java
===================================================================
--- utils/josm/plugins/ywms/src/org/openstreetmap/josm/plugins/ywms/ImageLoader.java	(revision 2282)
+++ utils/josm/plugins/ywms/src/org/openstreetmap/josm/plugins/ywms/ImageLoader.java	(revision 2283)
@@ -53,7 +53,8 @@
 	private URL yahooUrl;
 	double[] orig_bbox = null;
-	double[] final_bbox = null;
-	int width = -1;
-	int height = -1;
+    int width = -1;
+    int height = -1;
+    int final_width = -1;
+    int final_height = -1;
 	Image image;
 	List<String> firefoxFiles = new ArrayList<String>();
@@ -128,9 +129,12 @@
 	        {
 	        	System.out.println("YWMS::" + line);
-	            if( line.startsWith("bbox=") )
-	            {
-	            	final_bbox = getBbox(line);
-	                // System.out.println("YWMS::BBOX: (" + final_bbox[0] + "," + final_bbox[1] + "), (" + final_bbox[2] + "," + final_bbox[3] + ")");
-	            }
+                if( line.startsWith("new_width=") )
+                {
+                    final_width = (int)Math.round( Double.parseDouble( line.substring(10)) );
+                }
+                else if( line.startsWith("new_height=") )
+                {
+                    final_height = (int)Math.round( Double.parseDouble( line.substring(11)) );
+                }
 	            else if( line.startsWith(GECKO_DEBUG_LINE))
 	            {
@@ -168,11 +172,11 @@
 	        }
 
-	        if( final_bbox == null  && imageFilePpm == null && !firefoxFiles.isEmpty() )
+	        if( final_width == -1 && imageFilePpm == null && !firefoxFiles.isEmpty() )
 	        {
 	        	throw new ImageLoaderException("Is there any other firefox window open with same profile?");
 	        }
-	        if( final_bbox == null )
-	        {
-	        	throw new ImageLoaderException("Couldn't find bounding box. Is browser.dom.window.dump.enabled set in Firefox config?");
+	        if( final_width == -1)
+	        {
+	        	throw new ImageLoaderException("Couldn't find new dimension. Is browser.dom.window.dump.enabled set in Firefox config?");
 	        }
 	        if( imageFilePpm == null )
@@ -221,17 +225,10 @@
 	private void resizeImage() 
 	{
-		int calcwidth = (int)Math.round((final_bbox[2] - final_bbox[0]) * width / (orig_bbox[2] - orig_bbox[0]));
-		int calcheight = (int)Math.round((final_bbox[3] - final_bbox[1]) * height / (orig_bbox[3] - orig_bbox[1]));
-
-		int cropWidth = (calcwidth - width) / 2;
-		int cropHeight = (calcheight - height) / 2;
-	
 		Toolkit tk = Toolkit.getDefaultToolkit();
-        // save("/tmp/image_orig.jpg");
-        image = tk.createImage (new FilteredImageSource (image.getSource(), new CropImageFilter(0, 0, width, height)));
-        image = tk.createImage (new FilteredImageSource (image.getSource(), new ReplicateScaleFilter(calcwidth, calcheight)));
-        image = tk.createImage (new FilteredImageSource (image.getSource(), new CropImageFilter(cropWidth, cropHeight, width, height)));
-		// BufferedImage img = (BufferedImage)image.getScaledInstance(calcwidth, calcwidth, BufferedImage.SCALE_DEFAULT);
-		// image = img.getSubimage(cropl, cropt, width, height);
+        //save("/tmp/image_orig.png");
+        image = tk.createImage (new FilteredImageSource (image.getSource(), new CropImageFilter(0, 0, final_width, final_height)));
+        //save("/tmp/image_crop.png");
+        image = tk.createImage (new FilteredImageSource (image.getSource(), new ReplicateScaleFilter(width, height)));
+        //save("/tmp/image_scale.png");
 	}
 
@@ -265,9 +262,16 @@
 	 * @throws IOException When error saving the file
 	 */
-	public void save(String fileName) throws IOException
-	{
-        FileOutputStream fileStream = new FileOutputStream(fileName);
-        ImageIO.write(getBufferedImage(), "png", fileStream);
-        fileStream.close();
+	public void save(String fileName)
+	{
+        try
+        {
+            FileOutputStream fileStream = new FileOutputStream(fileName);
+            ImageIO.write(getBufferedImage(), "png", fileStream);
+            fileStream.close();
+        }
+        catch(Exception e)
+        {
+            e.printStackTrace();
+        }
 	}
 	
