Script to show JPEG degradation

Hello All,
I'm trying to demonstrate the degradation of jpeg's over multiple recompressions.
My planned approach is;
Open image;
Save image as new file at compression rate x;
Open the newly compressed file;
Loop;
I would like to run the script so I get 1000 images in a folder each x% of the previous image.
Does that make any sense?
If anyone has any ideas to help me i'd very much appreciate it.
tia
fess

Hi, sorry to be a pain.
I've had a go at adjusting the code;
// saves jpg multiple times;
// be advised: this closes the open file without saving and overwrites existing jpgs of the same name without prompting.
// 2011, use it at your own risk;
#target photoshop;
// set the number of saves;
var theNumber = 1000;
if (app.documents.length > 0) {
var thedoc = app.activeDocument;
// getting the name and location;
var docName = thedoc.name;
if (docName.indexOf(".") != -1) {var basename = docName.match(/(.*)\.[^\.]+$/)[1]}
else {var basename = docName};
// getting the location, if unsaved save to desktop;
try {var docPath = thedoc.path
     var thePath = docPath+"/"+basename+".jpg";
catch (e) {
     var docPath = "~/Desktop";
     var thePath = docPath+"/"+basename+".jpg";    
// save as jpg if not a jpg yet;
if (docName.indexOf(".jpg") == -1) {
// jpg options;
     var jpegOptions = new JPEGSaveOptions();
     jpegOptions.quality = 0;
     jpegOptions.embedColorProfile = true;
     jpegOptions.matte = MatteType.NONE;
//save jpg as a copy:
     thedoc.saveAs((new File(thePath)),jpegOptions,true);
// close doc;
thedoc.close(SaveOptions.DONOTSAVECHANGES);
//save jpg as a copy:
for (var m = 0; m < theNumber; m++) {
     File(thePath).copy(File(docPath+"/"+basename+"_"+bufferNumberWithZeros(m + 1, 3)+".jpg"));
     var thePath = docPath+"/"+basename+"_"+bufferNumberWithZeros(m + 1, 3)+".jpg";
     var thedoc = app.open(File(thePath));
// make change;
     thedoc.selection.selectAll();
     thedoc.selection.invert();
     thedoc.selection.selectAll();
     thedoc.selection.invert();
// save;
     thedoc.save();
     thedoc.close(SaveOptions.DONOTSAVECHANGES);
//that’s it; thanks to xbytor;
////// buffer number with zeros //////
function bufferNumberWithZeros (number, places) {
     var theNumberString = String(number);
     for (var o = 0; o < (places - String(number).length); o++) {
          theNumberString = String("0" + theNumberString)
     return theNumberString
When I run this code cs4 brings up a warning saying 'no pixels have been selected'. There is a check box to ignore future warnings. I assume it's my code?
I don't think I need the second selectAll but i'm not sure.
Am I being dense?
thanks once again

Similar Messages

  • Events script not showing up in designer

    I am working on a form using ES4 version 11 and when I try to view the Javascript code for the events nothing shows up.  I also cannot preview the form using the preview tab.  It just hangs.  When I quit and restart the form sometimes the script code shows up.  Any idas what may be causing this?

    Hi,
    This does happen to me sometimes, I'm guess that sometimes when an exception is thrown in one of the early events then the preview fails and the only way to recover is to restart Designer.
    Try going to the temp directory, just type "%temp%" (without the quotes in the Windows Explorer address bar), you should see a PDF file with a generated name something like, _12fk26d9o1adb71lh.pdf.  This is the file Designer generates when trying to do a preview.  Open this file in Acrobat (with the "When Exception is thrown" option set to break) and you should see what is causing the exception.
    Good luck
    Bruce

  • Scripts not showing up in console

    Hi all
    I have put my folder scripts in the correct location as far as I know but I can't get any scripts to show up.
    See the screenshot below
    Any Ideas?
    Trevor

    I hope this is the last one on this topic!
    With a one line script I can use the consul easily but lets say I have something really complicated like the script below. Other than fitting it on one line how can I run it from the console?
    for (var i = 0; i < 10; i++) {
        console.println(i);
    Ctrl Enter after the } throws the following error
    SyntaxError: syntax error
    1:Console:Exec
    undefined
    Sorry for asking such pathetically basic questions

  • Am using Adobe acrobat for iPad and pictures are showing JPEG and not PDFs

    I Am using Adobe reader for iPad and converted pictures from camera to ipad and pictures are showing JPEG and not pdf

    Hi bsmigs23,
    I'm not sure that I follow. You have the Adobe Reader app for iOS, and converting photos to PDF? Where are the photos showing up as JPEG? Do you see the converted PDFs when you look at the Recents List?
    Best,
    Sara

  • Show jpeg image in a block ?

    hi all,
    anyone try to show jpeg image in a multiple size block using image item?
    the image file is stored db with hughblog type. i have tried showing the bmp format. it is success. but if change to the image item to jiff format and then load the jpeg file. it shows nothing. did i miss any steps?
    thx in adv.
    alex
    Message was edited by:
    kyho

    hi philips,
    i didn't touch any read_image_file function. i just set the block to "table" and set the table name on the block's properties with the item name map to hughblog name. how to involve the read_image_file in my case?

  • Export to jpeg:  Show jpeg file size prior to export

    Photoshop save to jpeg dialog box shows the jpeg file size associated with each jpeg compression level (1 - 12).  Lightroom export dialog box does not show jpeg file size.  Showing the expected jpeg file size is useful when needing to limit file size while maximizing jpeg quality.  For example, some email applications limit attachment file size; some photo hosting sites (e.g., Zenfolio) limit file size to 12mb.  If I export a cr2 file at 100 quality, it may result in a file size of 14mb.  However, I cannot determine this until after I export.  Then I may try 90 quality and find that the resulting file size is only 8mb.  So, I try 95 quality, and get a 12.5mb file.  This iterative process is a waste of time.  I need to se the file size resulting from each jpeg quality setting in the export dialog box.

    I have tried trashing the plist file. The files look fine through the media manager when copied to the other profile. They look like they are suppose to. The small videos also look fine when played on that computer. Unfortunately our other mac pro computer doesn't have final cut so i can't open and play proress files and my laptop, due to the extreme resolution can't be played on my laptop with final cut studio installed. Tomorrow i'm going to install the proress decoder on the one mac pro to check the files and make sure the self contained is checked but i'm almost positive on that. Other than nuking the profile i don't know what else to do. This is really weird.

  • Need script to show hidden field if number =568845

    Hi All
    Using Acrobat 9.1 Pro on iMac with OS 10.6.8
    I am working on a fillable form and need a script to show a hidden field when a button is clicked.
    I have set up a number field to type in a number and the hidden field is"text1"
    Now I need a script for the button to only open the hidden field if the number field =568845
    That way the client can fill in the code and then show and type in the field.
    Any help would be appreciated.
    Ron

    Hi
    The field is hidden to begin with.
    Someone will fill out the form with all the other fields.
    But they will not be able to see the hidden field.
    When they email the form to my client, the client will type the number into the number field.
    Then the button to show the hidden field will have an if then statement that if the number field has the right number typed in then the button will show the hidden field, otherwise it will not be shown.
    It doesn't have to be a number, it could a word or name.
    All I need is the script for the if then statement.
    I am trying to use this script, but it doesn't work.
    if (event.value == 'Yes') { this.getField ('Hidden_Field').display = display.visible } else { this.getField('Hidden_Field').display = display.hidden }
    Ron

  • Linux Integration Service Version 3.5 installed and it shows "Network Degraded"

    In my Windows 2012 R2 , all my Linux virtual machines show "network degraded" in the Hyper-V manager.
    I installed the 3.5 version although the Fedora 20 kernel already comes with some hyper-v modules, looking to get rid of the message. I did not succeed, in fact, I am not shore if my new 3.5 modules are bring used or not.
    I type
    modinfo hv_vmbus
    filename:       /lib/modules/3.13.7-200.fc20.x86_64/kernel/drivers/hv/hv_vmbus.ko
    license:        GPL
    alias:          acpi*:VMBus:*
    alias:          acpi*:VMBUS:*
    depends:
    intree:         Y
    vermagic:       3.13.7-200.fc20.x86_64 SMP mod_unload
    signer:         Fedora kernel signing key
    sig_key:        C3:83:0B:47:32:E7:AE:9D:9E:43:FC:FB:76:F1:35:CC:8F:FF:60:9E
    sig_hashalgo:   sha256
    Can anybody tell me if I am using the latest modules, and if not, how can I make sure they do load?
    Federico
    ff

    I tried to compile Integration Services on RHEl 6.5, the latest of the 2.6 line, and compilation fails
    ./rhel6-hv-driver-install
    Building Modules
    make: Entering directory `/usr/src/kernels/2.6.32-431.11.2.el6.x86_64'
    make: Leaving directory `/usr/src/kernels/2.6.32-431.11.2.el6.x86_64'
    make: Entering directory `/usr/src/kernels/2.6.32-431.11.2.el6.x86_64'
      CC [M]  /usr/src/LIS3.5/hv-rhel6.x/hv/netvsc_drv.o
      CC [M]  /usr/src/LIS3.5/hv-rhel6.x/hv/netvsc.o
      CC [M]  /usr/src/LIS3.5/hv-rhel6.x/hv/rndis_filter.o
    /usr/src/LIS3.5/hv-rhel6.x/hv/rndis_filter.c: In function ‘rndis_filter_set_device_mac’:
    /usr/src/LIS3.5/hv-rhel6.x/hv/rndis_filter.c:579: error: incompatible type for argument 3 of ‘utf8s_to_utf16s’
    include/linux/nls.h:55: note: expected ‘enum utf16_endian’ but argument is of type ‘wchar_t *’
    /usr/src/LIS3.5/hv-rhel6.x/hv/rndis_filter.c:579: error: too few arguments to function ‘utf8s_to_utf16s’
    /usr/src/LIS3.5/hv-rhel6.x/hv/rndis_filter.c:584: error: incompatible type for argument 3 of ‘utf8s_to_utf16s’
    include/linux/nls.h:55: note: expected ‘enum utf16_endian’ but argument is of type ‘wchar_t *’
    /usr/src/LIS3.5/hv-rhel6.x/hv/rndis_filter.c:584: error: too few arguments to function ‘utf8s_to_utf16s’
    make[1]: *** [/usr/src/LIS3.5/hv-rhel6.x/hv/rndis_filter.o] Error 1
    make: *** [_module_/usr/src/LIS3.5/hv-rhel6.x/hv] Error 2
    make: Leaving directory `/usr/src/kernels/2.6.32-431.11.2.el6.x86_64'
    Installing Modules
    cp: cannot stat `./*.ko': No such file or directory
    Can somebody help?
    ff

  • JPEG degradation

    I'm aware that every time I open a JPEG file, edit it (ie rotation, contrast, color temp, etc), and then close the file that when the file is closed it goes through a decompression process resulting in some loss of image quality. My question is, does this decompression and loss of image quality happen every time the file is opened only for viewing (say a slide show)?
    Here is the main reason I have this question. As many of you have disappointingly learned, the Nikon D50 does not produce RAW files that iPhoto can read. Since I didn't really want to install and learn the Nikon software, I thought I'd just shot in JPEG Large/Fine and be satisfied with the image quality. But if every time I view my photos or show a slide show there is going to be some image degradation then I'll have to have a way to import Nikon D50 RAW files onto my computer.
    Thanks to anyone for any information.

    Scott,
    Nope. You lose nothing when you view an image. Don't think you will lose anything when you rotate an image either.
    Technically it goes through a recompression process.
    Also, iPhoto does a clever trick where it "remembers" the compression it used. So you edit a JPEG once and it shrinks the file. You can edit it as many times as you want after that and it won't compress or degrade the image any more. This is argueable though. Test it for yourself. Dupe an image and edit it ten times with minor adjustments (click the exposure icon to move it one pecent or something.) You'll see the file size shrinks the first time, but doesn't thereafter. Press the "2" key to enlarge both images to max size and compare. Most people can't really see a difference.
    RAW is good if the exposure of your images is off. It's main strength is that you can re-expose the image if you have a raw file. Then iPhoto makes a JPEG of it for editing anyway. So if your camera is producing good JPEGs, RAW is not really as great a thing as it's made out to be. Many pros shoot JPEG and feel that fooling with RAW is just another unnecessary step added to the process and takes up a lot of card memory they could be using for more images.
    Kevin

  • How do I get Firefox to show jpeg files in the same window/tab like it once did instead of asking me what to do everytime?

    For a long time, whenever I click on a jpeg link in one of my Yahoo groups, the image simply loads in the Firefox window or tab that I'm viewing and I can simply hit the back button to return to the page I was on before. But just recently when I click on a jpeg link, Firefox asks me where I want to download the file and I have to choose between opening another tab, using Windows Photo Viewer, or selecting another program, I believe this is unnecessary and cumbersome. I would like it if Firefox would simply show me the image I'm trying to view in the same window/tab like it used to instead asking me where to download it and/or opening up a new tab when I don't really need it.

    Hi Twistednerve84, <br>
    At the top of the Firefox window, click on the Firefox button and then select Options to access the options window. Go to the Applications Panel and next to 'JPEG image' content type select to use your default application to view images. <br><br>
    You can also find some information here: <br>
    [[Firefox options, preferences and settings]] <br>
    Please report back!

  • UI element-Image is not showing JPEG images

    Hi Gurus
       i am facing a problem while displaying an image in ImageUI,
    its not working with JPEG files, also its showing pblm while
    displaying gif images with size above some 50KB. Small size gif images are properly working.
    With Regards
       Vipin

    Hi Vipin,
    Regarding the image visibility, please check the permissions also.
    For eg:
    check with Read/Write permission for yourself and for others with Read permission.
    If you are displaying the images in WebDynpro application then you can allow/restrict the types of images like .jpeg or .png etc..
    Hope this helps..
    Regards
    Piyush
    Please reward points if this helps!!!

  • Read-image-file show jpeg photo cause error

    I use read-image-file to show a jpeg photo (edited by ACDSEE) cause frm-47100. I know that Oracle may not support the Jpeg format of ACDSee. But, anyone know how to solve this problem. (I have to keep using ACDSee)

    If you remove the metadata from a JPEG it should usually do the trick. I don't know how to do that in ACDSee, though.

  • Does adding captions to existing JPEGs degrade image?

    Using Photshop Elements 5.0, when I open an existing JPEG file and add a caption, the file's date stamp is changed to the current date, even if I don't actually edit the image.
    I know that opening, editing and then resaving an existing JPEG file causes the image quality to degrade each time this process is repeated, since the JPEG format format uses lossy compression. I'm wondering if adding a caption does the same thing, i.e., causes the image quality to degrade.
    Is adding a caption equivalent to editing the file, even if the actual graphic image isn't altered at the same time? Does adding captions to JPEG files after the fact cause image quality loss?

    No, adding a caption -- or a date/time, keyword tag, star rating, notes, or GPS location -- updates the file's metadata section without changing the actual photo. (That metadata is sometimes loosely referred to as EXIF, XMP, or IPTC.) So you don't need to worry about loss of image quality due to recompression.

  • Not all of my iTunes scripts are showing up in iTunes

    My itunes scripts are in Users/Apple/Library/iTunes/Scripts. Some of them show up and work in iTunes and some do not. I was wondering if anyone might know why? I am using iTunes 11.
    Thanks for any help.

    On itunes on my PC I see all of my films. If I use a device, lets say an iphone5, I go to the itunes store and then over to movies then over to "Purchased" and then to either "All" or "Not on this iPhone" certain films, like Tangled, don't show up. Same if I go to videos:movies, the icon for Tangled isn't there.

  • Bash script to show refreshing task list in terminal

    Hi all,
    Let me preface this by admitting that I am useless at scripting, so hopefully there will be an easy way to do this!
    I am trying to have a terminal running task (a todo list manager) that refreshes automatically. I would like to specify the window title for the terminal, so that awesome knows which tag to display it on.
    I figured watch is the easiest way to accomplish this - this strips out the colours, but I can live with that.
    If I run:
    watch task
    from a terminal, all works as expected and I get my todo list refreshing in the current terminal window.
    However, if I run:
    terminal --hold -e --title=tasklist -e "watch task"
    it opens a terminal window in the desired awesome tag with the todo list in, but it does not update.
    Instead of using watch, I have tried:
    while [ true ]
    do
    clear
    terminal --hold -e --title=tasklist -e "watch task"
    sleep 1
    done
    but this obviously opens many terminal windows all with the title "tasklist", rather than just one which is continually refreshed.
    I am sure there must be an easy way to accomplish what I am after, but I can't find it! Any help would be gratefully received.
    Thanks for all help,
    Stewart
    Last edited by sjg (2012-12-01 16:10:18)

    Have you tried looking at your music Library in "Browser" Mode?
    Edit Menu > Show Browser
    Then in the top "Browser" section, make sure the 1st section of "Genre" has "All" selected, then in the middle "Artist" section, you will see a list of all the artists in your Library. Clicking on each artist name should show all their songs as long as the last section, "Albums" has "All" selected

Maybe you are looking for

  • ICal search doesn't find anything

    when I test this by creating a future event with a particular word in it, then return to today and search for that word in the little "search" box at top right, it doesn't find that word. Why not?

  • Invalid Number Error in Merge Statement

    Hi all. I got an invalid number error in the following merge statement, but I don't know why. Maybe you can give me a hint. MERGE INTO wam_table USING (SELECT * FROM wam_table) b ON (b.username = 'user' AND b.mod = 'module' AND b.trimester = '1') WHE

  • T code BF 11  in LO

    Hi experts , i heard from someone while we r doing LO extraction there is an T code BF 11 was being using for purchase analysis data sources, i just want to know, From which steps the BF11 will take effect? like Rsa5-lbwe-lbwg accordingly plz answer

  • Gift card usage

    I am looking for how to use a gift card in the itunes store. I have an acocunt already, and have no problem purchasing songs with a credit card, but do not see anywhere to enter in the gift card. I looked at help and it says it should be in the accou

  • Why can't I delete music from my iphone using itunes match anymore?

    I thought for sure I used to be able to swipe to delete albums or tracks on my iphone - on my iphone 5 I can no longer do this. I found that if I turn itunes match off, I can delete. But turning itunes match on and off a lot is really a huge issue. I