Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to control the size of images and graphics?

I've been having trouble arranging graphic elements correctly. Here's an example:

im1 = Import["http://upload.wikimedia.org/wikipedia/commons/5/5c/London_2010_Tower_Bridge.jpg"];
GraphicsRow[{im1, ImageAdd[im1, Graphics[Disk[]]], Graphics[Disk[]]}]

example of problems

The circles are both specified in the same way, but show at different scales, so the diagram that attempts to show how it works isn't very satisfactory. Obviously one is scaled to match the image, but I can't see why they don't appear the same size. Row is similar to GraphicsRow but gives me the same problem.

like image 255
cormullion Avatar asked Dec 11 '11 20:12

cormullion


People also ask

How do I reduce the MB size of a photo?

The Photo Compress app available at Google Play does the same thing for Android users. Download the app and launch it. Select the photos to compress and adjust the size by choosing Resize Image. Be sure to keep the aspect ratio on so the resizing doesn't distort the height or width of the photo.


2 Answers

The problem occurs because in the display, the disk used in the mask has a diameter equal to the height of the image, whereas the stand-alone disk has a diameter equal to the width of the image. You can correct this by specifying the size of the disk explicitly.

im1 = Import[
   "http://upload.wikimedia.org/wikipedia/commons/5/5c/London_2010_\
Tower_Bridge.jpg"];
disk = Graphics[Disk[], ImageSize -> ImageDimensions@im1];
GraphicsRow[{im1, ImageAdd[im1, disk], disk}, Spacings -> 0, ImageSize -> Full]

enter image description here

like image 70
abcd Avatar answered Sep 30 '22 18:09

abcd


Another option would be to wrap the images in a Pane with automatic width and fixed height, e.g.

Row[Pane[#, {Automatic, 200}] & /@ 
 {im1, ImageAdd[im1, Graphics[Disk[]]], Graphics[Disk[]]}] 

scaled to have the dame height

like image 22
Heike Avatar answered Sep 30 '22 20:09

Heike