Hi Vlasta,
It's been a long time since you wrote this batch operation. I don't know if you're even still around, but if you are, can you help with this error?
I have the images:
blue-1_16.png
blue-1_32.png
blue-2_16.png
blue-2_32.png
and so on.
They are in the same folder. If I run the batch operation, I get "Object doesn't support this property of method."
screenshot
https://i.imgur.com/P6hEyWS.png
For reference, I'll paste the code below.
I'm using Windows 10 and RWIE 2016.1.
Any ideas? -Steve
// place your custom JavaScript code here
var path = Configuration.path;
if (path.charAt(path.length-1) != "\\")
path += "\\";
var separators = Configuration.separators+".";
// obtain .ico filename
var basename = Document.Name;
for (var i = 0; i < basename.length; ++i)
{
var stop = false;
for (var j = 0; !stop && j < separators.length; ++j)
stop = basename.charAt(i) == separators.charAt(j);
if (stop)
{
basename = basename.substring(0, i);
break;
}
}
// open the previous icon or create a new icon
var prev = Application.OpenDocument(path+basename+".ico");
var prevIcon = null;
if (prev) prevIcon = prev.Icon;
if (prevIcon == null)
{
var newIco = Application.CreateWizard("1EA02660-391E-484F-B1E0-3154F28C28BD");
newIco.Type = 0; // no initial images
prev = Application.CreateDocument(newIco);
prevIcon = prev.Icon;
}
if (Document.SupportsFeature("RasterImage"))
{
var image = Document.RasterImage;
if (image.SizeX > 256 || image.SizeY > 256)
{
Context.ErrorMessage = "Invalid image size";
Context.StopProcessing(false);
}
var newFormat = prevIcon.CreateFormatID(image.SizeX, image.SizeY, 32);
prevIcon.InsertImage(newFormat);
var newImage = prevIcon.GetImage(newFormat);
Blender.Compose(newImage, 0, 0, image.SizeX, image.SizeY, image, 0, 0, 0, Blender.OpSrc);
}
if (Document.SupportsFeature("Icon"))
{
var icon = Document.Icon;
var formats = icon.FormatIDs;
for (var i = 0; i < formats.length; ++i)
{
var format = formats[i];
prevIcon.InsertImage(format);
var newImage = prevIcon.GetImage(format);
var image = icon.GetImage(format);
Blender.Compose(newImage, 0, 0, format.SizeX, format.SizeY, image, 0, 0, 0, Blender.OpSrc);
}
}
prev.SaveCopyAs(path+basename+".ico");
EDIT: Forgot to mention, I tried it starting with PNGs and also tried starting with ICOs. Each had the same error.
EDIT 2: I guess that it would also be excellent if the batch operation could instruct RWIE to remove/crop the blank pixels from around the large images. My (above) post suggest 32x32 images, but I'm actually using 128x128.