61
Ideas/Suggestions / Re: Stamps: Filename (without file extension)
« Last post by nightslayer23 on October 07, 2022, 07:53:21 AM »How can we add more font choices to the list?
It seems the ActiveX ImageMagickObject is not included anymore in the installer (Windows Installer option ImageMagickObject is missing).
Get the old version installer, that includes it, from the Wayback Machine website. Don't forget to select the "Install ImageMagickObject OLE Control for VBScript,..." when installing it.
That's functionality not directly available from the scripts API but we can create a script to automate the ImageMagick tool and get that info.
The idea is to render each PDF page and analyze the result bitmaps for color content.
Made some test and here is a sample script that creates a .csv file with a "Color Pages Count" and "BW/Gray Page Count" columns. It renders each PDF page, converts the result bitmaps to the HSI colorspace and computes the mean value of the saturation channel. The page is considered colorized if this value is higher than 0, or BW/Gray otherwise. You may adjust this threshold to your needs.
To test it, just import the attached .myscript file into the PDF-ShellTools My Scripts, and you will get a "Number of Color and BW/Gray pages" named script, you can invoke for all the selected PDF files from the Windows shell PDF files context menu, from the PDF-ShellTools>My Scripts sub menu.
The scrip needs to have the 32-bit version of the ImageMagick tool installed. I've tested with the ImageMagick-7.0.5-5-Q16-x86-dll.exe one. While installing, make sure you select the "Install ImageMagickObject OLE Control for VBScript,..." option, under the "additional tasks" page of the installer.
The ImageMagick also needs to have the Ghostscript tool installed, to handle the PDF format.
If the script is performing as needed we can change it to put the info into custom metadata properties, as you suggested.
var ProgressBar = pdfe.ProgressBar;
ProgressBar.max = pdfe.SelectedFiles.Count;
for (var i = 0; i < pdfe.SelectedFiles.Count; i++) {
ProgressBar.position = i + 1;
var file = pdfe.SelectedFiles(i);
var Page = file.Pages(0);
if (Page) {
var w = Math.min(Page.Width, Page.Height);
var h = Math.max(Page.Width, Page.Height);
var PSizeStr = w.toFixed() + 'x' + h.toFixed();
var FileMetadata = file.Metadata;
if (FileMetadata.PageSize !== PSizeStr) {
FileMetadata.PageSize = PSizeStr;
if (FileMetadata.CommitChanges()) {
pdfe.echo(file.Filename + ' : (' + PSizeStr + ') [OK]');
} else {
pdfe.echo(file.Filename + ' [commit changes failed]', 0xFF0000);
}
} else {
pdfe.echo(file.Filename + ' : (' + PSizeStr + ') [already set]');
}
}
}
pdfe.echo("Done");