Is this a way of scaling images?

Hi,
I've got a few questions regarding image scaling and need some advices on whether my method is correct or to throw away as quickly as possible...
I've defined all my website images in "ems" so that they rescale when the user zooms in/out the page or decreases/increases the font. I thought this would be good for accessibility purposes (?).
There are 2 tedious things with that system:
1. the image dimensions must be computed in ems,
2. the image dimensions depend on the text font size used on the page.
If I change the page font size but want to keep my images as they were previously displayed, I need to go through these calculations again. It very quickly gets seriously annoying.
I found one way of avoiding this: I define font-size:1px for each image. The great thing is that since I have body {font-size:100%}, it turns out that when the image has font-size:1px, then its dimensions are the same in pixels or ems. I mean that if I want to display my image with width:50px and height:10px, then I just need to specify width:50em and height:10em. Or at least the result is close enough not to be seen different to the naked eye. This only is useful if I am not modifying too much the page font size, e.g. font-size:0.95em to font-size:1.05em. So I thought this is great! But... there always are associated problems.
Problems found so far:
1. This only works if applied to the image, not its container (e.g. a floating div), so that the font-size doesn't propagate to any child element, e.g. a caption below the image.
2. If the image is inside a div that is floated, then I need to set a width for that div and this width needs to be calculated with respect to the normal page font size, not my 1px—if this makes sense. If I were to change my image dimension, then I'd need to change this width too.
3. It works fine with IE and Firefox, but no Safari and Opera.
Hence the following questions:
- Is this method totally absurd (as it probably sounds after my description) and/or infringing some basic rules?
- Is there anything simpler?
- Why doesn't it work in Safari or Opera?
I'd be very grateful for any comment on this. Having started HTML and CSS only 1.5 month ago and not full time, I have no feeling at this stage whether this is a correct or acceptable way of thinking or not...
Emilie

- Is this method totally absurd
Yes. Scaling images is very easy. Unless all your images are the same width, you will need to create an attribute selector for each image, but the principle is the same for each one.
Let's say you have an image called mypic01.jpg, which is 600px wide.
Remove the width and height attributes from the <img> tag. This displays the image at its normal size.
Create the following style rule:
img[src$="mypic01.jpg"] {
  width:50%;
  max-width:600px;
This makes the image 50% of the size of its parent element, but ensures that it never grows bigger than its maximum size. Just use the image name in place of "mypic01.jpg", and adjust the correct value for max-width.
The only drawback is that this won't be supported by IE6, which will simply display the image at its normal size. If it's important to support IE6, change from an atttribute selector to an ID selector like this:
#mypic01 {
  width:50%;
  max-width:600px;
Add the ID to the <img> tag:
<img src="mypic01.jpg" alt="my scaling image" id="mypic01" />
IE6 will ignore the maximum width, but will scale the image to 50% of the size of the parent element.

Similar Messages

  • Black background when scaling images with transparent background

    I am implementing Zooming functionality for reports which have some icons. I am trying to scale icon by scaling its image. But the problem I am facing is that the icons have transparent background and the scaling puts a black background in place of transparent. Is there any way to maintain its transparency or better yet, Is there anyway to put a white backgound instead of the black one that is created by default ? Here is my code
         public static Icon getScaledIcon(Icon icon){
             if(icon instanceof ImageIcon){
                  Image outImage = ((ImageIcon)icon).getImage();
                      return new ImageIcon(getScaledImage(outImage));
             }else{
                  Image outImage = new BufferedImage(icon.getIconWidth(),
                            icon.getIconHeight(),
                            BufferedImage.TYPE_INT_ARGB);
                    JComponent comp = new JComponent(){};
                    icon.paintIcon(comp, outImage.getGraphics(), 0, 0);
                    return new ImageIcon(getScaledImage(outImage));
        public static Image getScaledImage(Image image){
             image = image.getScaledInstance((int)(image.getWidth(null) * getScale()),
                           (int)(image.getHeight(null) * getScale()), Image.SCALE_SMOOTH);
            return image;
        }I haven't done much image manipulation , so I would really appreciate any help or advice.

    I have also not done much of image work. But I guess you could achieve your functionality of showing scaled image in the screen by not scaling the image and show it, instead scale the image in paint method by calling g.drawImage giving the height and width. But use high resolution images so that scaling is good.
    If you do in this manner, you could give any colour you want as background to fill the transparent area or leave it as such.
    Regards,
    techece.

  • Is there a way to rotate images in iPhoto on the ipad

    I take photos with the iPhone or iPad and unless I sync them back to the Mac, there does not seem to be a way to rotate images. This makes having a nice slideshow (for the unlock screen) a problem as a bunch of images are all sideways. I'd like to be able to do simple edits like this in the device and not have to sync back and forth.

    You can't in the Photos app itself, though there are third-party apps that allow you e.g. PS Express (though the saved rotated version of the photo will be put in the Saved Photos album).

  • Is there a way to avoid image "compression/downscaling" on the iPad yet??

    Is there a way to avoid image "compression/downscaling" on the iPad yet??
    I'm sick of saving/downloading/transferring images to my iPad, only to find them being downscaled when saved to the device..
    Is anyone aware of a way to change this?? <edited by host> 
    I would very much like my images to remain the original resolution..
    Thanks!

    Nothing has changed. If your camera transfers raw images to the iPad, these are not touched. Copies that work with the iPad's resolution are also created during the transfer. When you sync with your computer the untouched raw images are what get transfered.
    But the iPad is a viewinf device, not a transfer device from computer to computer, so if you sync photos from your computer to the iPad, those are provisioned to the iPad's resolution.

  • HT1479 I would like to know how to burn a dvd in such a way that each image can be skipped over by pressing the skip button.

    I would like to know how to burn a dvd in such a way that each image can be skipped over by pressing the skip button? If anyone could help it would be greatly appreciated!

    Here's how top get a slideshow that will let the viewer manually control the forward and backward movement of the slides with the forward and back buttons on the DVD remote.
    1 - put the images you want to use in an iPhoto album.
    2 - launch iDVD, select a theme and add a slideshow using the "+" button at the bottom:
    3 - click on the Media button at the lower right hand corner of the window and then click on the Photos button.
    4 - locate the iPhoto album containing your photos and drag it into the left hand pane:
    5 - select Side Duration to Manual.
    In order to get the maximum manual control of the slides you cannot have add any music to the slideshow.  If you do add music the slideshow will continue you advance unless you pause the slideshow and/or use the advance/back buttons and then pause.
    Once you have the project as you want it save it as a disk image via the  File ➙ Save as Disk Image  menu option.  This will separate the encoding process from the burn process. 
    To check the encoding mount the disk image and launch DVD Player and play it.  If it plays OK with DVD Player the encoding was good.
    Then burn to disk with Disk Utility or Toast at the slowest speed available (2x-4x) to assure the best burn quality.  Always use top quality media:  Verbatim, Maxell or Taiyo Yuden DVD-R are the most recommended in these forums.
    OT

  • Is there a way to import images that have been edited and assign them to the original?

    I am transitioning to mac and aperture. Is there a way to import images that have been edited and assign them to the original? I have 10,000 originals and about 2,000 edited images. The originals are named img_XXXX and anything modified img_XXXX_modified. I would like to be able to import the originals and then import the edited versions and assign them to the original masters. Instead of starting from here and going forward with 12,000 masters, some of which are actual originals and others not. Thanks for the help.

    Ah, the vestiges of a destructive workflow! Once you "get" Aperture, (specifically Masters and Versions) you are going to love it, as all of this work goes away - the relationship that you seek to retain is automatic in Aperture; it is simply done differently.
    The short answer to your question is EVERY image file that is Imported into Aperture will create a new Master and one Version. Assuming that your images are PSD/TIFF/JPEG that you created in something like Photoshop, then each one that your import will be a new Master. You have many options:
    -- Stick the originals in one Project(s) and the edited versions in another Project(s).
    -- Stick them all in the same Project(s) and "Stack" them.
    But here is the real question: Why are you doing all of this work and what are you trying to accomplish? Seems you are trying to preserve old things that don't need preserving in a non-destructive workflow.
    So, what is most valuable to you?
    -- The original, out of camera files? (That is, the fear/need to revert.)
    -- The edited versions? (That is the hours of work that it took you to get there.)
    If the former, import the originals and ignore the edited versions. (Either simply leave them out on disk or import them into their own Projects which you ignore.) Use Aperture to recreate the work you had done previously. This will always give you the ability to revert to the original Master and create as many Versions as you want. This is the best idea if your edits are relatively simple crops and exposure adjustments,
    If the latter, then import the edited versions and do as above with the originals. This makes more sense if your work uses lots of layers and, perhaps lots of clone tool type corrections.
    Of course, you can do a bit of both.
    Others may have better suggestions, but you will find it easy to answer your own question when you understand an image based, as opposed to a file based, non-destructive workflow.
    Good luck!

  • I'm thinking of using Final Cut Pro to straighten slightly crooked footage and then re-import back to iMovie to complete the video. Does this have any impact on image quality?

    I'm thinking of using Final Cut Pro to straighten slightly crooked footage and then re-import back to iMovie to complete the video. Does this have any impact on image quality?

    As your rotate the image, you will begin to see black edges. So, as Tom implies, the image must be scaled up to hide those voids. If you shot 4k ad are editing in a HD timeline, no problem, lots of room to spare. If you shot 1080 and are editing in a 1080 timeline, you will run into issues at a certain point. However, if your 1080 project is going to be transcoded to 720 or ye olde DVD you won't notice any deterioration at all.

  • I am using a MacBook Pro.  I simply cannot find a way to attach images adjusted in Lightroom as attachments and/or without massive degradation in quality.  I follow the LR attach email process as specified by LR, the photos appear in the email seemingly e

    I am using a MacBook Pro.  I simply cannot find a way to attach images adjusted in Lightroom as attachments and/or without massive degradation in quality.  I follow the LR attach email process as specified by LR, the photos appear in the email seemingly embedded and the recipients of the email cannot save the attachment.

    You are welcome.  Just finished a chat session with an Apple support rep and confirmed the matte option no longer available.  Seems lots has changed since I bought my 17” 19 months back:).  They did say that there were after market screen films available from places like amazon
    Have never used anything like that though.  My wife has a 2008 MBP 15” with gloss and I can say it is a nice screen finish, you just have to be careful of lighting from behind you.  All my iMacs were glossy and I did learn to compensate for the added brilliance the screen brought to the photos.  The new soft proofing feature of LR5 seems to better estimate the level of brightness of the printed work, compared to past versions of the s/ware.
    In any case, in my opinion you really can’t go wrong with the apple product.  I bought my first iMac in mid 1999 and have never looked back.  I donated that machine to a pre-school in 2008, it was running OSX version 2 or 3 I think.  I did run Photoshop 7.0 on an IBM laptop for a time (windows XP).  I think I had one of the very first versions of Adobe Camera Raw on that machine.  I digress, sorry.
    The chat representative did confirm that the 17” is out of production and I’m guessing Apple found the market for the big laptop just wasn’t there.  They did mention that 17” MBP’s show up as “certified refurbished” units from time to time.  Suggest you might explore that option with a local Apple store in the UK, assuming  Apple has store front operations off this continent of course.
    Please feel free to contact me with further questions if you wish.
    Take care, Gordy

  • Most efficient way to handle Image sizes with respect to Mobile Screen Size

    Hi all,
    I and trying to find the best possible way to manage Images with respect to the size of mobile screen.
    If I have an image that is best fit on mobile screen size (176 x 144) then how can I make it best fit for (128 x 128) screen size ?
    rizzz86

    Hey Rizzz86,
    You could also scale down a higher resolution image to fit smaller screens, however you will find that resizing by factors other than 2, 4, 8 is harder to achieve with a decent quality and much slower on lower spec devices.
    You could also display 128x128 image centered on 176 x 144 screen with black borders around it.
    It will look not that bad (i.e. borders of 24 pixels top and bottom and 8 pixels left and right) and will cost you nothing in terms of space or processing.
    In the end having an image in 3 different sizes will not increase the MIDlet size by much, unless you are having tens of such images (for example custom UI elements).
    Best solution is to have a bit of both I think. Personally I use scaling down by factors that are powers of 2 and displaying with the black borders.
    Daniel

  • Scaled image doesn't appear

    Hi, can someone tell me why the scaling of the image does not work in the code below.
    I making a board game application with these inherited JLabel components used to display each players piece on a background created using an inherited JPanel. The image is correctly displayed on the JPanel at the correct location.
    The problem I'm encountering is that when I attempt to scale the image used the scaledInstance method it doesn't appear on the board but appears perfectly if I use the default image (comment out the scaled instance part of the line).
    I've tried downscaling as well increasing size, in case the image is too large and putting absolute values in but to no avail.
    Any help would be appreciated.
    Thanks
    package UserInterface;
    import java.awt.*;
    import javax.swing.*;
    public class PieceIcon extends JLabel
        //Create new image with the piece (symbol) chosen by the player
        public PieceIcon(String symbol,int pNum)
            playerNumber = pNum;
         pieceImage = new ImageIcon("./Images/"+symbol+".jpg").getImage().getScaledInstance(10,10,Image.SCALE_DEFAULT);
            // above line works if scaled instance part removed, even though scaled image smaller
            setOpaque(false);
        public void paintComponent(Graphics g)
           super.paintComponent(g);
           g.drawImage(pieceImage,boardPos[0][(MainFrame.getPlayer(playerNumber).getCurrentBoardPos())],
                                  boardPos[1][(MainFrame.getPlayer(playerNumber).getCurrentBoardPos())],this);
        private Image pieceImage;
        private int playerNumber;
        private static int[][] boardPos = (set of relative positions here, not displayed to make post easier to read)

    bump

  • Is there a way to add images to the collection used in Photomerge Style Match?

    When one uses the menu: Enhance->Photomerge® Style Match, there will be six images displayed to choose from. The path to them is (Mac):
    /Application/Contents/Resources/models/ While this menu is only available in Expert mode, you end up in Guided when you choose it. I assume, therefore, that there is actually an Action or at least a script.
    Simply adding an image wouldn't work, which I confirmed. Even rebuilding the MediaDatabase.db3 didn't help. But there must be more than just the simple jpeg that the app uses to perform the effect... or maybe not! ;-) All I'd like to know is if there is a way to add images to the list of choices.
    Thanks!

    What version of photoshop elements and mac os x are you using?
    Once your in the Style match screen you add images using the Green Plus button
    (the screenshot is from photoshop elements 12)

  • Is there a way for my images that are links NOT to be denoted by whatever color i set my links to be in my page properties?

    Hi there.
    i have set my links to be black in my page properties.  i have somes images that i am using for links and i do not want the to have a black box tracing their outline.  it's messing up my design and tables.  is there a way for my images that are links NOT to be denoted by whatever color i set my links to be in my page properties?
    see attachment.
    thanks for sharing your knowledge with me.
    gina

    If you would like your NON-linked images to have a border, and only remove the border from linked images then this css:
    a img { border:none; }
    E. Michael Brandt
    www.divahtml.com
    www.divahtml.com/products/scripts_dreamweaver_extensions.php
    Standards-compliant scripts and Dreamweaver Extensions
    www.valleywebdesigns.com/vwd_Vdw.asp
    JustSo PictureWindow
    JustSo PhotoAlbum, et alia

  • Quick, easy ways to make images look better?

    What are the best ways to make images look a bit better? I shot my footage using a pretty bad camera, so quality already isn't the greatest, but what is the best way to make images look a bit more "movie-like"? The 3way color correstion is nothing for me, it's too hard to make images look good, they'll quickly turn too yellow or red, etc... Something to improve contrast maybe? Using Image Control: Brightness and contrast (bezier) doesn't seem to help much.

    Okay, I took a couple of screenshots:
    http://www.majhost.com/gallery/TheDarkBrickX/Random/film/afbeelding_1.png
    http://www.majhost.com/gallery/TheDarkBrickX/Random/film/afbeelding_2.png
    http://www.majhost.com/gallery/TheDarkBrickX/Random/film/afbeelding_3.png
    http://www.majhost.com/gallery/TheDarkBrickX/Random/film/afbeelding_4.png
    Now I don't know alot about image quality or color, but I think there is not enough contrast? It all looks very cold. Luckily, image quality isn't the most important thing in this project, but it would be nice to be able to touch it up a little bit.

  • Scaling image files for Slide presentation in Keynote

    I have had great problems importing and scaling images for Keynote presentations with approx 500+ images. Having tried to adjust the image to fit the full screen the scaling results in unacceptable pixelation. I seem to have solved this now by batch processing my image files and saving them as PDF files. These are then imported from the Aperture Library as iPhoto wont recognise the PDF file format!
    It's a pity that Keynote has so many restrictions for use in Slide/music presentations, having seen incredible professional results with Pic2exe (which unfortunately at present is not available in Mac format - tho the Win exe file will run I am told).

    Please tell us what you are really trying to do!!
    You know like dumb stuff like where are the images from? What's their resolution? If you';re using Aperture you can't be a newbie. 
    You can achieve incredible professional results in Keynote, but you need to know how it wants to work.
    Kelly is right. This is not just a ***** session but a place to get real help from real people.
    Silly things like Image Placeholders will make your life much simpler. etc.

  • Best way to manage images in a swing app

    Hi.
    I have a swing app that uses alot of images around 100+ at around 40kb each.
    I am currently using new ImageIcon("icon\\main.png")) to create them.
    Is this the most efficient way to manage images?
    Would it be more efficeint to store then in the mysql database?
    and / or use SwingWorker (http://java.sun.com/javase/6/docs/api/javax/swing/SwingWorker.html)
    Cheers
    Bobby

    Hi Bobby,
    It depends on what you want to be more efficient:
    1) CPU cycles
    2) Reducing jar size
    3) Ease of maintenance
    4) Prevent typing errors in file names
    For me, number 3 and 4 are important. So, what I generally do, is create an enum that desribes the images that are contained in the same package as the enum. Now I'm able to change the package name with no consequence. I only have to type the filename once and know when I have to double check of what I type. Something like this:
    package org.pbjar.geom.images;
    import java.awt.image.BufferedImage;
    import java.io.IOException;
    import java.net.URL;
    import javax.imageio.ImageIO;
    import javax.swing.ImageIcon;
    public enum Images {
        AUTHOR_SMALL("TheAuthor.jpg"),
        AUTHOR_LARGE("PietKopLarge.jpg"),
        private final String filename;
        Images(String filename) {
         this.filename = filename;
        public ImageIcon getIcon() {
         return new ImageIcon(getImage());
        public BufferedImage getImage(){
         try {
             return ImageIO.read(getURL());
         } catch (IOException e) {
             throw new RuntimeException(e);
        public URL getURL() {
         return this.getClass().getResource(filename);
    }Piet

Maybe you are looking for