Quick preview of jpeg using subsample

Hey,
Consider that you have a folder with many "medium sized" JPEGs, let's say: 2MB, 500KB, or so...
You want to explore that folder, without loading all files into memory, but in the same time you want to see a small preview of each image file (just like windows thumbnails).
Loading every single jpeg will cost you a lot of memory... so here comes SourceSubsampling.
I use following lines for reading jpegs:
public Image CreateImageFromFile(File file) throws InterruptedException, IOException {
        ImageReader reader= (ImageReader)(ImageIO.getImageReadersByFormatName("jpeg").next());
        ImageReadParam param = reader.getDefaultReadParam();
        ImageInputStream iis = ImageIO.createImageInputStream(file);
        reader.setInput(iis,true);
        param.setSourceSubsampling(16,16, 0, 0);
        Image img=null;
        try {
             img = reader.read(0,param);
        } catch (Exception e) {System.out.println("Error read");
        return img;            
    }Before using this method... I have used a simpler way:
FileInputStream FI=new FileInputStream(file);
IMAGE_Cobai=Toolkit.getDefaultToolkit().createImage(FI);
The first issue was... Loading TIME. I got 500 ms for a 2.5MB. It is acceptable for a single file, but for 10 or 100?!
The second issue was MEMORY. BufferedImage ate a lot of memory, sometimes I got some errors for exceeding max memory allocated for JVM (80MB or?!)
I solved the second, using first method (subsampling).
I wonder why the LOADING TIME is the same?
Is there any way to speed it up?* I thought that using setSourceSubsampling will force reader to simply ignore most of pixels and maybe read only one pixel for every 16x16 block.
It should be possible because comercial products like ACDSEE use these tricks for preview. Strange thing is I didn't find any library for java...
If you have some answers... pls write them here. I googled a lot... last 2-3 weeks.
Thx.

I posted a reply here that might help - see the post on 2008-06-06:
http://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.html?page=last#thread

Similar Messages

  • Quick Preview old zoom function

    If i remember correctly, in old Quick Preview when i use "option+coomand N" i was able to "Coomand +/- " zoom in full screen.
    It seems it is fixed in Lion. Any idea for that?

    I don't see "option+command+N" as a working short cut in the current version of Preview. "Command +/-" seem to work fine in full screen mode for me.

  • Applescript to convert PDF to JPEG using Preview?

    I know there's an existing script available on the internet that converts PDFs to JPEGs (it's here: http://macscripter.net/viewtopic.php?id=25350) BUT, for whatever reason, the quality, even when set to 600dpi, is crap. I get better results simply opening the PDF in Preview then saving as JPEG... even a 150dpi JPG from Preview is higher quality than a 600dpi file from this script I found...
    So, what I need help with is creating a applescript that converts PDF's to JPEGs using Preview (or whatever, as long as the quality of the JPEG is good). I have very little scripting experience so help is appreciate.
    Ideas?
    Thanks.

    Frank Caggiano wrote:
    Decided to finish this up as an interesting exercise. Hope you find it useful.
    One question for the  Applescripters here. The Automator action run as a shell script seems to return a list of filename aliases but the return value while looking like a list didn't behave as a list. I managed to rip it apart to get to the filepaths and the script works but it seems really kludgey . So my question is given the return of the Automator run as a do shell script what is a more correct way to handle it?
    Convert PDF to JPG
              © 2011 Frank Caggiano
              GNU Public License
              Convert pfd files to jpg images.
              The converted JPG files wil have the name of the original PDF files with the extension changed to JPG.
              The actual conversion uses the Automator action Render PDF Pages as Images.
              The user needs to create an Automator action with Render Pages as Images as the single action.
              Set the parameters for the conversion in the action.
              NOTE: this script assumes you're converting to jpg files If you select another output format in the action this script will
              need to be modified.
    -- choose PDF files
    try
              set sourceFiles to choose file with prompt "Select PDF files" of type {"com.adobe.pdf"} with multiple selections allowed
    on error msg number n
              if n ≠ -128 then
                        error "Unknow error: " & msg & space & n
              else
      quit
              end if
    end try
    -- choose destination folder
    try
              set destFolder to choose folder with prompt "Select Destination Folder"
    on error msg number n
              if n ≠ -128 then
                        error "Unknow error: " & msg & space & n
              else
      quit
              end if
    end try
    set destFolder to quoted form of POSIX path of destFolder
    -- select workflow
    try
              set workFlow to choose file with prompt "Select Work Flow" of type {"com.apple.automator-workflow"}
    on error msg number n
              if n ≠ -128 then
                        error "Unknow error: " & msg & space & n
              else
      quit
              end if
    end try
    set workFlow to POSIX path of workFlow
    repeat with sourceFile in sourceFiles
      -- get base name of the source file
              set bName to do shell script "basename " & quoted form of POSIX path of sourceFile
      -- Strip off the extension
              set text item delimiters to "."
              set bName to text item 1 of bName
              try
                        set res to do shell script "automator -i " & quoted form of POSIX path of sourceFile & space & workFlow
              on error msg number n
                        error msg & space & n
              end try
      -- Seems strange to  do it this way but it works
              set text item delimiters to "\""
              set theList to text items of res
    We go through the list of converted files. If there is more then one then the second and subsequent files
    will get and integer added to the name to avoid conflict.
              set cnt to 0
              repeat with convertedFile in theList
                        if convertedFile does not contain "alias" and convertedFile does not contain "}" then
                                  set fullPath to quoted form of POSIX path of convertedFile
                                  if cnt ≠ 0 then
                                            do shell script "mv " & fullPath & space & destFolder & bName & "_" & cnt & ".JPG"
                                  else
                                            do shell script "mv " & fullPath & space & destFolder & bName & ".JPG"
                                  end if
                                  set cnt to cnt + 1
                        end if
              end repeat
    end repeat
    Hi Frank--
    I tried the script you wrote and created the Automator workflow with the single action as requested, saved it to the desktop then selected it when your script's dialogue requested it. However, at that point your script game me the following error. Ideas? I did save the workflow as a workflow and I selected it directly, so I'm not sure why it thinks that the "workflow file does not exist" ? :
    error "The workflow file does not exist. 255" number -2700 from «script» to item

  • Aperture quick preview locks in after using Google/Nik to edit a photo

    I'm not sure when this started happening, but I've recently been annoyed with very frequent restarts of Aperture being required. 
    If i edit a photo with any of the Nik/Google programs, save it, and get back to my project full of photos...the quick preview stays locked onto the original of the photo I just editted.  It doesn't even update to the edit of it. I thought my library was large and bogging the system down or something, so i made a new library and imported 4 photos, editted one, and it's still doing the same thing. Any thoughts?
    I did a quickie search, but I'm terribad at searching in these forums. Sorry if it's somewhere obvious to you pro searchers

    hey thanks so much! ok, ill jsut deal with editing one photo at a time and then restarting aperture each time.. lol its ANNOYING, but it WORKS.. so ill deal with it!
    thanks again!!!
    oops, i tried to change it to you solved my issue instead of helped, and i think i marked that i solved my own problem.. ugh i hate these forums! lol

  • Quick preview acting up

    Hi,
    I spent the last few days reorganizing my Aperture library and migrating from managed to referenced files.
    The problem I'm having is that Quick Preview doesn't work with the embedded JPEGs. It does work with the previews created by Aperture but they always stay somewhat fuzzy thanks to the scaling algorithm in Aperture/OSX.
    Aperture does use the embedded JPEGs on newly imported images.
    My question is: is there any way to get Aperture to read those embedded JPEGs again ?
    The fuzzyness (even though it's subtle) is killing me since I mainly use quick preview to quickly assess image sharpness and delete the unsharp images quicly after import.
    What I've tried:
    - Delete the stored previews (this results in 1024x768 images in preview that get scaled up to full screen and are small when I press Z in full screen mode)
    - Rebuilt previews (1/2 size, quality 7): this results in somewhat workable images but still with some fuzzyness and absolutely not as sharp as the embedded JPEGs.
    - I've consolidated the masters to see if it's caused by the Referenced masters system (it isn't). I've moved them out of the library again afterwards.
    - I've rebuilt the library and did a consistency check.
    It affects all my projects that were in the library prior to the reorganisation. And once again: newly imported images work properly, so quick preview isn't "broken" completely.
    Any ideas on what I could try ?

    The other option (which I'm considering) is to use referenced libraries and import the Raw+Jpg into Aperture. Then do a "new master from Jpeg on the raw files displayed. The jpg's are now displayed as a version. With referenced libraries, you can delete the versions without losing the raw file. If you can use the jpg, great. If you want to edit the raw, simply do a "show in finder" from under the file menu and drop the nef into NX and do your "in-camera" edits such as Picture controls ect.... Then export the file as jpg or tiff and drop back into your aperture project. I'm leaning this way to avoid using another application and Aperture is clearly more capable than View. One of the advantages of View, however, is there is an "open in NX" function. You cannot use Apertures' "edit with" command to open the raw file. It will only render a tiff or jpg to an outside app. It would be nice to be able to open the native raw file in NX using this function. Not a big deal with the "show in finder" option and referenced libraries.

  • Quick previews often soft

    When I scan through my images using quick preview, sometimes they are soft with no colour change and sometimes there is a colour change (as if auto levels was applied)/images become sharper. For consistent sharpness I need to have quick preview turned off otherwise some images look soft.
    How does quick preview work and why am I getting inconsistent behaviour? Is it based on the RAW files or does it use the JPEG and what if you only shot RAW? The above behaviour occurs whether I shot RAW or RAW+JPEG?
    If I want to get sharp looking images do I need to have Aperture generated previews turned on? I currently have this turned off. And would this result in consistent sharpness in Quick preview mode?
    Ross

    quick preview uses the embedded JPEG in the RAW file. It may well look different than the Aperture generated preview. If your screen resolution is larger than the JPEG then it will likely be soft.
    RAW+JPEG won't change anything -- the JPEG and the RAW file when imported this way are considered different master files.

  • Fuzzy previews with Quick Preview

    Good evening, all. I recently upgraded from a 1st gen MacBook to a brand new 20" iMac. Now, with the new machine, I'm noticing that my images (captured in RAW, naturally) when displayed in Quick Preview mode while in full screen mode are fuzzy and pixelated, as if I'm zoomed in more than 100%. If I turn off Quick Preview mode, the image will render normally. Below are two 100% crops of screen captures taken with Quick Preview on and off.
    fuzzy (Quick Preview on):
    clear (Quick Preview off):
    I'm shooting with a Canon 40D. I didn't notice this on my MacBook, but the screen is much smaller there. My preferences in Aperture (v2.1, by the way) are as follows:
    ("Use embedded JPEG from camera when possible" enabled, Preview quality: 8 Medium
    Limit preview size: Fit within 1680 x 1680 (*))
    It would appear that if I generate a preview with the above settings and view the image in full-screen mode with Quick Preview enabled, then the fuzziness is gone. I've only tested this with one image, but it seems to hold across restarts of Aperture.
    I used exiftool to pull out the embedded preview image from the .CR2 file. That preview file appears to be 1936 x 1288 pixels, so it should fit on my display without being zoomed to fit.
    Has anyone else experienced this problem? It really makes it difficult to judge focus when processing images. I'd like to conserve space by not generating previews, hence my current configuration.
    Thanks,
    Brian

    Yes, "p".  Full instructions are in the always helpful (well, almost always) User Manual:
    Quick Preview Mode

  • AP 2 and Sony A700 embedded JPG Quick Previews?

    The Sony A700 RAW and cRAW images contain an embedded high quality JPG image designed for viewing on HDTV. If the camera is set to 3:2 aspect ratio it is 1616 x 1080 pixels (and if set to 16:9 then it is 1920 x 1080).
    Aperture 2.0 does not appear to make any use of these large embedded JPGs in Quick Preview even though I have selected " Use embedded JPG from camera if possible".
    It is not clear if this could be forced by limiting the size of previews to either slightly smaller than or larger than the size of the embedded JPGs from the camera?

    Does anyone know an answer to this question? I'm using the Aperture 2 trial and I like the software for cataloging but since I'll use Capture NX for most of my editing it would be great if I could get Aperture to display the embedded jpg in preview mode. But it doesn't. I've checked that box in the Preferences. I've deleted the previews for the project. I've made sure that Maintain Previews isn't checked. But I still don't get the embedded jpg in preview.
    By the way, I know what the embedded jpg should look like since it does display properly when importing into Aperture.
    Any help appreciated.
    David

  • Why is my Quick Preview taking ages to load

    I am finding the Quick Preview in Aperture is taking a long time to load the picture. I have to come out of quick preview to allow the picture to load and be clear. Once it has loaded, I can go back in to QP and it works as expected. Until I try to open the next picture.
    This has only started recently.Is it something to do with looking at masters instead of versions?

    My first (and perhaps only) guess is that you have (perhaps inadvertently) set Aperture to not create Previews (or deleted them).
    What happens if you select all the images in a Project and execute "Photos→Update Previews"? Does Aperture do anything?  Are you then able to quickly move through them using Quick Preview?

  • Thumbnail/Quick Preview/Export have strange grey overlay

    I spent quite some time googling this issue, so it's starting to seem like a "just me" issue. Yet I can't find a way to solve it, so here I go asking for help.
    I have a library with a single project and a series of photos in it. Most photos have a crop, white balance, exposure, sharpen and curve global adjustments, as well as areas with definition brush strokes and dodge brush strokes. The dodge brush was used to make the "almost white" background around product in the shot completely white.
    The thumbnails display a light grey (around 250;250;250 RGB, although it varies a bit) blotchy overlay in the areas of the image that are expected to be white. When I click on a thumbnail to bring up the larger image into view, for the first few seconds, while the "loading" spinner is visible on top, the grey overlay can also be seen on the enlarged image. After loading is finished, it disappears. If I turn on the Quick Preview mode, the grey overlay persists and does not go away. Images that I have viewed enlarged with Quick Preview turned off continue to display correctly when I come back to them after looking at other images, as if they are cached in memory. After I view a few dozen images, though, these correct versions seem to be evicted from cache, and I get the grey overlay during the "loading" period again.
    The grey overlay does not correspond one-to-one with the area where brush strokes have been applied.
    The scariest part of it all is that when I try to export versions, they are exported with the grey overlay intact.
    I have tried rebuilding thumbnails, reprocessing masters, repairing permissions, repairing the database. The problem persists. I have tried disabling the dodge adjustment but unchecking it and then checking it again. The problem persists. I have tried removing the dodge adjustment and then brushing it on from scratch. The problem persists.
    Out of ideas now. Please help. I would love to attach screenshots, but don't see an option to do so.
    Message was edited by: antonzzzz

    All you are seeing is the difference between the fully-decoded image created on the fly by applying the adjustments saved as instructions in the Version text file to the Master image file, and the Preview created according to the parameters you set in Preferences.
    If the Previews don't meet your needs, try a higher quality/larger dimensions.
    Likewise for your exports.
    What are your Preview and Export settings?
    Take a look at the highlighted section
    How Aperture Displays Images in the Viewer
    on this page in the User Manual.

  • Quick Preview unusable - images are "squared"/blurred

    Hi,
    Probably since 3.1.2 upgrade or 10.6.7 or turning on Time Machine I am experiencing following behavior:
    I have project for my family photos in aperture for this Year where I have folders for months and then albums for events. I usually drag and drop the selected images from Import browser to appropriate album.
    The problem is when I use Quick Preview - then all of imported images (in whole Album, but not project) are "squared"/blurred (you can imagine that like if you take image 200*200 and resize it to 1680*1680) - the small and middle preview are squared and the biggest and fullscreen are clear.
    When I turn of the Quick Preview then the Loading... appears and clear the image. I can then turn on the Quick Preview and it stays clear until I restart the Aperture and squared image is back.
    When I start the Aperture and select the album/project it automatically starts processing (Processing IMG_XXXX) some, seems random, number of images) - and nothing happened. (turn off and turn on Aperture and processing starts again).
    Here is what I tried (no success with anything):
    - Delete preview and generate new previews
    - Copy to other project
    - Change the size of the preview image (from 1680*1680 to 1920*1920) in Aperture preferences
    - Change preview image quality to 9 from 8 in Aperture preferences
    - Export the project as New library - this has one effect - the biggest preview and fullscreen image are squared here also
    - applied all file permissions to files as are by default on Picture folder
    - Repaired permissions
    So in summary:
    - preview pictures are squared
    - aperture does not remember/store the smaller quick preview files after restart
    And here is a example of the image:
    http://dl.dropbox.com/u/17422374/example-squared.png
    Thank you for any help or ideas to try.
    Regadrs
    Princatko
    Mac OS X 10.6.7, with FileVault turn on
    Aperture 3.1.2, masters are in Aperture Library, Library sits in ~/Pictures/ (default place)
    Canon 5D Mark II

    Since you've covered most everything (inc. permissions repair), it's probably time to move on to "Repair Database" and then, if needed, to "Rebuilt Database".
    Instructions are found on [the general trouble-shooting page.|http://support.apple.com/kb/HT3805]

  • Quick preview/ How do I disable Hot&coldSpotw

    Hi, in the first version of Aperture I had no Hot&Coldspots in my Quickpreviews. Now I do have this al the time in Aper 3. How can I shut this off. I only would like to have this in my normal view.

    Either push "Shift + Option + H" or use the menu command "Highlight Hot & Cold Areas" under the "View" menu.
    When you enter quick preview, it's locked on/off depending on the setting you are currently using. I don't believe there is a way to change this behavior in Aperture.

  • Quick preview looks better than processed raw image...??

    Hey all, probably a bit of a "newb" question here... so forgive me, and thank you...
    Using a D7000 and often times when I shoot - the preview image on the camera looks BRIGHT, VIVID and ROBUST ... after import however - when reviewing my shots, JUST as I arrow over to the next shot - many of the preview images tend to look better than the processed image that aperture displays once it's done spinning it's wheels.
    Perhaps I've messed up a Raw Fine Tuning setting?
    When I click on quick preview and browse through an import, the pictures truly look nicer to me than the when aperture processes them.
    Without question, the display on my acer monitor is a far cry from the miniature compressed image on the back of my nikon, however the more i shoot, the more I realize a disconnect between what I think I should see, and what I'm ultimately seeing in Aperture.
    Are their specific settings to fine tune the import of raw d7000 shots?
    Thanks much.. gk

    I take it you're shooting and processing RAW images?
    It's worth remembering that if you have a picture style selected (i.e. vivid etc), your camera might be applying extra contrast and saturation etc to the image you see on the back of the camera. Camera manufacturers do this so that we can give our pictures some extra punch and colour automatically.
    I'd also be wary of comparing what you see on your camera to what you see on your monitor. Unless both are calibrated, you shouldn't trust either of them 100%. The best example of monitor calibration is going to look at TV's in an electronics store. You'll probably notice that in a wall of TV's, some pictures will be darker, some lighter, some more vivid, some more saturated. Using a calibration tool adjusts the picture your screen and monitor displays so that it is 'accurate'.
    It's a bit like having a room full of scales and adjusting them so that they all read 1 kilogram when a 1 kilogram weight is placed on each of them. Calibrating monitors will mean that when you display an image on it, it will always look the same rather than getting the some light/some dark problem you saw in the TV store.
    It's a tricky subject to explain (don't worry if it doesn't make sense), but you might like to have look around YouTube for videos on the subject.

  • Quick Preview toggle - images appear very soft?

    I have noticed that when using Quick Preview to run through images in my projects all images appear sharp, however if I toggle quick preview off and then back on again the image never sharpens.
    This is similar to the effect you would get on first view, i.e. an initial soft image that sharpens when loading completes.
    Has anyone else noticed this?

    Hi guys:
    I came searching for this same problem and only happened upon a solution (at least for me) very accidently. In my case the "softness" doesn't seem to be actually linked to the "quick preview" toggle.
    When I pull down the "view" menu from the top of the screen, I pass the "quick preview" command and go down to the bottom to "Proofing Profiles". The profile for the proofing was set to one of many of my printer's profiles, which was not calibrated, yet, for my mac. I selected, instead, a previously saved calibration setting (one that I made using the simple calibration wizard under the monitor system preference) specifically for my monitor, and the viewer image changed to look exactly as the one in Browser thumbnail; sharp and detailed.
    I certainly hope that this may help you. As I said, this is not based on in-depth knowledge of this program, just trial and error, so may not apply to your situation.
    Good Luck
    Arcody

  • Quick preview issues

    I’m using a late 2008 MBP and SL 10.6.4 with AP3. After importing around 5000 RAW to a new project, quick preview in full screen isn’t working properly. Viewing the photos in full screen at full resolution is not an issue. Only when switching to quick preview, the image disappears and the screen goes black. When flipping through the photos in full screen and quick preview on, the photos flash up for a blink of an eye before the screen goes black again.
    What I’ve tried so far is to delete and generate new previews, repair permissions and the library and rebuild the library. However, as a result all projects now have the same issue. Moreover, photos aren’t shared with other (iLife) applications. The projects in the photo browser in Mail as well as the control panel for desktop background are empty. Sharing with iTunes, i.e. syncing photos on my iPhone, doesn’t work (again, projects have 0 photos). Of course, sharing is enabled in AP preferences. I’ve read several articles about this sharing problem but the solutions posted didn’t work for me. As sharing uses the jpg files, I guess this is somehow related to the quick preview issue.
    It seems that for some reason Aperture does not read the jpg files. Any ideas what else I can try to solve this? Thanks!

    Unfortunately, I do not have a solution for you because I am struggling with a similar problem since the release of AP3. I have also experienced the blink of an eye appearance and disappearance of some previews. Also, sometimes the thumbnails and the preview pictures shown are unrelated, or the previews are scrambled. I have tried every AP2 to AP3 conversion strategy in the book; the result is always the same. Hope Apple finds a solution for this quickly.

Maybe you are looking for

  • Get all values from multi select in a servlet

    Hello, I have a multi <select> element in a HTML form and I need to retrieve the values of ALL selected options of this <select> element in a servlet. HTML code snippet <select name="elName" id="elName" multiple="multiple"> Servlet code snippet respo

  • 3D does not work in Photoshop CS6 on my Dell i7 laptop

    Hi Problems with 3D objects. PS freezes every time I create a 3D object and try to come out of 3D mode or save the file. TRIED: Updating driver for ATI Mobility Radeon HD560V display adapter AMD website auto-suggested and installed HD 4650 (?) driver

  • How to pass Multi and Singlr value Parameters to DB2 query, which is using in SSRS report for ODBC connection

    Hi Guys, I am using DB2 database in SSRS. I have to pass Single Value and Multi Value Parameters. I tried with Select * From DB2Table Where Column=@PRM_Name Or Select * From DB2Table Where Column=:PRM_Name . It is not working and throwing error. Plea

  • Quicktime 10...lack of settings/preferences

    Are there any sort of settings or preferences that can be changed in Quicktime 10? Specifically, I miss some of the features of the old Quicktime such as how it would automatically mute any videos playing behind the one in the window currently select

  • IPhoto won't import .mov video from iPhone

    I just got my wife a new Mac mini.  It is running the latest versions of Mountain Lion and iPhoto. She's recorded some short videos of the kids with her iPhone (4s), and wants to organize these in iPhoto alongside pictures of the kids (she's done thi