"Combine Icons" batch operation not working in RWIE... - RealWorld forums

Log-in or register.

"Combine Icons" batch operation not working in RWIE...

kunkel321
on February 24th 2016

Hi Vlasta,
I'm trying to use your batch op that you wrote, to combine a bunch of icons. They are .png files of different sizes.
Screenshot: http://i.imgur.com/duu0OKJ.png
(this only shows a small portion--they are in different folder)
I keep getting "Object does support this property of method."
I tried changing the the "Open as:" from Layer Image to "Raster" "Rendered" and "Not set." None of those worked...

Any ideas what I might be going wrong? I'm using RWIE 2015.1 on Win 7 64bit.

The code is this:
=============BEGIN
var path = Context.GetState("OutputFolder");
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");
===================END

Vlasta
on February 24th 2016

Before I dig deeper, is this the old script? Because there may be a built-in updated version of this in 2015.1 beta.

kunkel321
on February 24th 2016

99% sure it's the built in... 1% don't remember though. How do I confirm? The .rwbatchop file would be in the program folder in Appdata/Pluggins/ right? It is empty.

As a side note, I had the RWIE window showing on my external monitor. The monitor is now unplugged, but the window GUI is still appearing in the same (now off screen) location...

Vlasta
on February 24th 2016

Here is an updated version of the script. It should work:

var path = Context.GetState("OutputFolder");
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;
	var fmts = prevIcon.FormatIDs;
	for (var i = 0; i < fmts.length; ++i)
		prevIcon.DeleteImage(fmts[i]);
}

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, prevIcon.RGB22A8);
	prevIcon.InsertImage(newFormat, image);
}

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, icon.GetImage(format));
	}
}

prev.SaveCopyAs(path+basename+".ico");

Is Windows still configured to work with 2 monitors (can you still move your mouse out of the first one)?

kunkel321
on February 24th 2016

This does work! Many thanks! :-)

Regarding the monitor, it's my Dell laptop. THe extra monitor is hooked up to my docking station. When unplugged from the docking station, the mouse cursor does, indeed, stop at the edge. If I click the RWIE button on the Windows Taskbar to maximize/minimize the window, then it looks like the GUI window is flying over to the right edge and flies off-screen. It might be a problem with my computer (?), as I've seen a couple different applications do this.

Another odd behavior: I thought I'd try converting my multi-sized .png files into .ico format, then combining the .icos.... When using the built-in "Create icon from image" batch op, the .png does not convert to .ico.... It becomes samename.png.ric
This happens with one, or with multiple png files. I can try with .jpeg, etc, if you want me to.

Vlasta
on February 24th 2016

Yes, it seems like the file extension is not right in the current build, the file itself should be a proper icon though. I will have to fix that.

Anonymous
on December 12th 2019

As a side note, I had the RWIE window showing on my external monitor. The monitor is now unplugged, but the window GUI is still appearing in the same.
thanks for information

Page views: 2534       Posts: 7      
I wish there were...
Select background
What about ICL files?