Create New Image using Image Events

Hello all.

Had a looking at the Image Events tutorial, and else where on the inter webs, but, whilst it appears well documented for the manipulation of images, Image Events doesn’t have much in the way of Creation

Here’s what I have so far, and I’m guessing that the Save and Close are somewhat superfluous:

	tell application "Image Events"
		set the new_format to PNG
		set location to POSIX file "~/Desktop/ipadbackground.png" as alias
		make new image at location with properties {dimensions:{1536, 2048}, file type:PNG}
		save location
		close location
	end tell
end try

Ut doesn’t err, but, then again, it doesn’t seem to do anything either

The dictionary appears somewhat scant too:

make v : Create a new object.
new type : The class of the new object.
[at location specifier] : The location at which to insert the object.
[with data any] : The initial contents of the object.
[with properties record] : The initial values for properties of the object.
→ specifier : The new object.

Ideas? Requirements literally are to be able to, without 3rd party tools, make a new image of PNG with iPad mini 4 dimensions

Image Events is an image-creation tool.

With the upmost respect, I thought that was very evident in my post:

What do you want in the image?

Just an empty image. I’mm naively assuming that, like any other image app, if you create a new image, it’s either transparent (like a PNG) or White, or something else dependant on the app used

Worst case scenario, I’ll take an image that p[re exists on the Mac and use SIPS at the command line, or Image Events to resize.

use AppleScript version "2.5" -- macOS 10.11 or later
use framework "Foundation"
use framework "AppKit"
use scripting additions

set thePath to POSIX path of (path to desktop)
set posixPath to thePath & "Test.png"
set bitmapRep to (current application's NSBitmapImageRep's alloc()'s initWithBitmapDataPlanes:(missing value) pixelsWide:1536 pixelsHigh:2048 bitsPerSample:8 samplesPerPixel:4 hasAlpha:true isPlanar:false colorSpaceName:(current application's NSCalibratedRGBColorSpace) bytesPerRow:0 bitsPerPixel:0)
set theData to (bitmapRep's representationUsingType:(current application's NSPNGFileType) |properties|:{NSImageGamma:1.0})
(theData's writeToFile:posixPath atomically:true)

Thanks Shane

I hadn’t seen any other evidence of people using Image Events to create but had seen examples of this!


I meant: Image Events is not an image-creation tool.

That makes more sense. Thanks! :slight_smile: