Tuesday, November 19, 2019

#1 2019-10-14 04:15:38 am

Woggledog
Member
Registered: 2012-12-06
Posts: 155

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:

Applescript:

try
   tell application "Image Events"
       launch
       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.
make
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

Offline

 

#2 2019-10-14 05:34:22 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 6034

Re: Create New Image using Image Events

Image Events is an image-creation tool.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

#3 2019-10-14 05:37:02 am

Woggledog
Member
Registered: 2012-12-06
Posts: 155

Re: Create New Image using Image Events

Shane Stanley wrote:

Image Events is an image-creation tool.



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

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

Offline

 

#4 2019-10-14 05:49:40 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 6034

Re: Create New Image using Image Events

What do you want in the image?


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

#5 2019-10-14 06:04:31 am

Woggledog
Member
Registered: 2012-12-06
Posts: 155

Re: Create New Image using Image Events

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.

Offline

 

#6 2019-10-14 06:16:03 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 6034

Re: Create New Image using Image Events

Applescript:

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)


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

#7 2019-10-14 06:19:46 am

Woggledog
Member
Registered: 2012-12-06
Posts: 155

Re: Create New Image using Image Events

Thanks Shane

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

Cheers!

Offline

 

#8 2019-10-14 06:24:58 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 6034

Re: Create New Image using Image Events

Shane Stanley wrote:

Image Events is an image-creation tool.



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


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

#9 2019-10-14 07:02:35 am

Woggledog
Member
Registered: 2012-12-06
Posts: 155

Re: Create New Image using Image Events

That makes more sense. Thanks! smile

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)