Bug in CS4 resizeImage?
Posted: Mon Oct 27, 2008 10:28 pm
Hi All.. I have a script I've been using in CS3 to export images in Full Size JPEG and then 1200 pixels on longest axis).
The script basically 'hangs' at the call to rezizeImage. RAM usage goes to max and it basically does nothing ..
The line in question causing the hang is
Code: Select alldoc.resizeImage(undefined, newImgSize, undefined, ResampleMethod.BICUBICSHARPER)
I've tried using ResampleMethod.NONE but it doesnt make any difference.
Full script is below.
Code: Select all// SaveJPEG.js
// some code and resources found on internet
//
//
odoc = app.activeDocument;
var doc = app.activeDocument.duplicate();
//
doc.convertProfile("sRGB IEC61966-2.1",Intent.RELATIVECOLORIMETRIC,true,true);
app.displayDialogs = DialogModes.NO;
//
var filePath = decodeURI(odoc.path);
var fileName = decodeURI(odoc.name).slice(0,-4);
//Set restore pointvar savedState = doc.activeHistoryState;
//
// Produce the full size jpeg image in 10 quality
SaveFile = new File(filePath + "/" + fileName + "_FullSize.jpg");
SaveJPEG(SaveFile,12);
//
// call subroutine to resize to 1200 pixels on widest axis
fitImage(1200);
//
// Produce the 1200 pixel jpeg in 10 quality
SaveFile = new File(filePath + "/" + fileName + "_1200.jpg");
SaveJPEG(SaveFile,12);
// call subroutine to resize to 400 pixels on widest axis for thumbnails
//fitImage(400);
// Produce the thumbnail in 7 quality
//SaveFile = new File(filePath + "/" + fileName + "_Thumb.jpg");
//SaveJPEG(SaveFile,7);
doc.close(SaveOptions.DONOTSAVECHANGES);
alert("Image Saved!");
function fitImage(newImgSize) {
var doc = app.activeDocument;
if (doc.width > doc.height) {
doc.resizeImage(newImgSize, undefined, undefined, ResampleMethod.BICUBICSHARPER)
}
if (doc.width < doc.height) {
doc.resizeImage(undefined, newImgSize, undefined, ResampleMethod.BICUBICSHARPER)
}
if (doc.width == doc.height) {
doc.resizeImage(newImgSize, newImgSize, undefined, ResampleMethod.NONE)
}
}
function SaveJPEG(saveFile, jpegQuality){
jpgSaveOptions = new JPEGSaveOptions()
jpgSaveOptions.embedColorProfile = true
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE
jpgSaveOptions.matte = MatteType.NONE
jpgSaveOptions.quality = jpegQuality //1-12
app.activeDocument.saveAs(saveFile, jpgSaveOptions, true,Extension.LOWERCASE)
}
Any help would be greatly appreciated.
The script basically 'hangs' at the call to rezizeImage. RAM usage goes to max and it basically does nothing ..
The line in question causing the hang is
Code: Select alldoc.resizeImage(undefined, newImgSize, undefined, ResampleMethod.BICUBICSHARPER)
I've tried using ResampleMethod.NONE but it doesnt make any difference.
Full script is below.
Code: Select all// SaveJPEG.js
// some code and resources found on internet
//
//
odoc = app.activeDocument;
var doc = app.activeDocument.duplicate();
//
doc.convertProfile("sRGB IEC61966-2.1",Intent.RELATIVECOLORIMETRIC,true,true);
app.displayDialogs = DialogModes.NO;
//
var filePath = decodeURI(odoc.path);
var fileName = decodeURI(odoc.name).slice(0,-4);
//Set restore pointvar savedState = doc.activeHistoryState;
//
// Produce the full size jpeg image in 10 quality
SaveFile = new File(filePath + "/" + fileName + "_FullSize.jpg");
SaveJPEG(SaveFile,12);
//
// call subroutine to resize to 1200 pixels on widest axis
fitImage(1200);
//
// Produce the 1200 pixel jpeg in 10 quality
SaveFile = new File(filePath + "/" + fileName + "_1200.jpg");
SaveJPEG(SaveFile,12);
// call subroutine to resize to 400 pixels on widest axis for thumbnails
//fitImage(400);
// Produce the thumbnail in 7 quality
//SaveFile = new File(filePath + "/" + fileName + "_Thumb.jpg");
//SaveJPEG(SaveFile,7);
doc.close(SaveOptions.DONOTSAVECHANGES);
alert("Image Saved!");
function fitImage(newImgSize) {
var doc = app.activeDocument;
if (doc.width > doc.height) {
doc.resizeImage(newImgSize, undefined, undefined, ResampleMethod.BICUBICSHARPER)
}
if (doc.width < doc.height) {
doc.resizeImage(undefined, newImgSize, undefined, ResampleMethod.BICUBICSHARPER)
}
if (doc.width == doc.height) {
doc.resizeImage(newImgSize, newImgSize, undefined, ResampleMethod.NONE)
}
}
function SaveJPEG(saveFile, jpegQuality){
jpgSaveOptions = new JPEGSaveOptions()
jpgSaveOptions.embedColorProfile = true
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE
jpgSaveOptions.matte = MatteType.NONE
jpgSaveOptions.quality = jpegQuality //1-12
app.activeDocument.saveAs(saveFile, jpgSaveOptions, true,Extension.LOWERCASE)
}
Any help would be greatly appreciated.