Hello, I'm looking to create a Powershell script that will allow me to process images based on their file size: any image that comes in over 1 MB gets processed, the rest get ignored. Unfortunately I'm having a bit of trouble integrating NConvert with Powershell, and I'm honestly not sure if this is due to my relative lack of Powershell knowledge or if there really is some issue with NConvert and Powershell (and as such if this is the right place to be asking).
This is the only way I could get it to work, as adding the $Dir at the end of the NConvert segment caused it to error out. However, running this code doesn't modify based on the file size, it just processes everything in the folder.
Any help would be appreciated, and I do apologize if this is the wrong place to be asking. Thank you!
I would suggest you first test your NConvert code in isolation and get that running, if you haven't already done so, and then test it with your PowerShell code.
And as you need to use a wildcard in the NConvert input term, I would suggest testing initially with no spaces in the input term path, and also without quotes, to avoid any possible conflict with wildcards: my recollection from past experience is that quotes may not be used with a wildcard when there are spaces in the input term path, although I think spaces in the input filename itself are permissible.
Another possible point to consider is that when NConvert code is run in a batch file the '%' character must be doubled to '%%' to escape it: if the same consideration applies to NConvert code run in PoweShell, your resize term would need to be modified.
Finally, if you have NConvert code that is confirmed as good and still can't obtain the result you need, you will probably need to seek assistance with the PowerShell code elsewhere...
Well, the issue was with Powershell, not with NConvert. Myself and one of the guys I work with managed to cobble together a working script (which is below if anyone wants to use it for the same reason).
I hate to be a bother once more but I had one other question: is it possible to lower the quality of an outputted file with NConvert? I know XnConvert lets you set the quality in the output tab but I'm not seeing anything to do something similar with NConvert.
benchmarkjoshw wrote:I hate to be a bother once more but I had one other question: is it possible to lower the quality of an outputted file with NConvert? I know XnConvert lets you set the quality in the output tab but I'm not seeing anything to do something similar with NConvert.
If you're outputting to a JPEG there is a -q term you can use to set the quality, if you could check the Help file as I'm out of the house at the moment; you could try this revised line in your code:
benchmarkjoshw wrote:I hate to be a bother once more but I had one other question: is it possible to lower the quality of an outputted file with NConvert? I know XnConvert lets you set the quality in the output tab but I'm not seeing anything to do something similar with NConvert.
If you're outputting to a JPEG there is a -q term you can use to set the quality, if you could check the Help file as I'm out of the house at the moment; you could try this revised line in your code:
-o filename : Output filename
Use # to specify position of numeric enumerator
Use % to specify source filename
Use $ to specify full source pathname
Use $$ to specify source folder name
Use $EXIF:DateModified[date format] to specify EXIF date modified
Use $EXIF:DateTaken[date format] to specify EXIF date taken
Date format: Please check documentation of strftime
Anyway, it somehow solved the immediate issue even so...