I'm using Automator for the first time, trying to manipulate (resize and pad) many images at once. I've created a workflow that consists of several actions and an AppleScript at the end to perform some basic If/Then logic (since my images are in different orientations, and need to be padded accordingly).
Here is my workflow (screencap):
And, my crappy AppleScript:
on run {input, parameters}
set this_image to input
set target_H to 600
try
tell application "Image Events"
-- start the Image Events application
launch
-- extract the properties record
set the props_rec to the properties of this_image
-- get dimensions of the image
copy (dimensions of props_rec) to {W, H}
-- determine the shortest side and then
-- calculate the new length for the longer side
if W is greater than H then
set pad_dimensions to {W, 600}
set the scale_dimension to target_H
end if
-- perform action
pad this_image to dimensions pad_dimensions with pad color {255, 255, 255}
-- save the changes
save this_image with icon
-- perform action
scale this_image to size scale_dimension
-- save the changes
save this_image with icon
-- purge the open image data
close this_image
end tell
on error error_message
display dialog error_message
end try
return input
end run
I just want to continue making changes to the same image I started with in the automator workflow, but can't seem to keep going when I switch to AppleScript. Thanks in advance for your time/help!
I only looked at the first 2 lines of your code and spotted a common error. Notice your first action "Ask for Finder items". Notice "items", it's plural. Even though you select only 1 image file you will get back a list which can hold many image files. So your list will hold only one item but it's in a list. That list is passed to "Copy Finder Items" which is plural too so you're good. The stuff from the first action will be handled properly by the second action... and so on until it hits your applescript.
Now in your applescript a list of items is passed as "input". So your second line of code doesn't get an image, it gets a list. If you want the image from the list you have to get item 1 from the list...
set this_image to item 1 of input
Now you have the image and Image Events can do its thing. I didn't look at your Image Events code but I think you'll have to open this_image first and get properties and resize the opened image. So you probably have to do something like this...
tell application "Image Events"
-- start the Image Events application
launch
-- open the image
set openedImage to open this_image
-- extract the properties record
set the props_rec to the properties of openedImage
And so on. You'll be manipulating openedImage, not this_image, which means you'll need code to save openedImage when you're through.
Good luck.
Related
I have a set of data consisting of 3 values, being time, dataValue, dataQuality. I'm trying to get the line color (not the marker because that is working) color set based on the dataQuality. The current graph is rendered based on time (x-axis) and dataValue (y-axis) and dataQuality is currently not used or shown.
What I would like tot have is the line color based on the data quality instead of the data value, all while rendering data value for the line.
Is this possible to achieve within hightcharts?
Edit: To clarify with an image, as requested. The red line is the only line I'd like tot render, the grey one is here solely to show the quality value for the data. So what I'd like is the red line to go grey (or whatever we decide it to be) as soon as the data from the other line drops below a threshold. The markers, even though done with paint here, are already done by setting the color value for individual markers grammatically when processing the incoming data. The grey line should not be rendered at all.
Alright, having a night of sleep over it helped. Instead of trying to do it the hard way, by using invisible values I though of another way to solve this.
I do know the timestamps for low quality points. I started using the timestamps on the x-axis to create zones with different colors. Which color for which zone is determined by the data quality.
when I see the backtest results, there is a Result panel( Ref. e.g.: https://quivofx.com/wp-content/uploads/2015/02/result.png )
that listed all transactions for the backtest.
Is there a way to quickly scroll to the relevant portion of the graph?
For example, say buy on 2017.05.03 10.30 EURUSD 5 Min, I would scroll to that portion by just e.g., double click on the entry?
Currently, it is pretty slow for me to go back and forth to check for result entries by scrolling the Graph manually.
double click on trade entry or modification or exit and you will see that picture (of course if you ran the test with visual mode=true)
press space bar and type data and time then press enter - you will see that the chart moves to the indicated date
Another fast & built-in method available:
The fastest jump to an exact datetime value in the MT4 Graph works via the mouse double-click inside the graph's time scale area, near the lower-left corner, where a small gray triangle is present.
A mouse, positioned there for a while, shows a self-explanatory label Double click for editing
Next, one may type-in or copy/paste there any datetime target as one wishes to move to.
2016-12-12 08:00
and hit ENTER
So,
1) using mouse-select ( over a legitimate datetime value as seen in Strategy Tester results et al )
2) Ctrl-INS to copy into a paste buffer
3) Alt-TAB to get into MetaTrader Terminal 4 Graph, if Results were copied from WebBrowser, not from a Strategy Tester sub-window panel in MT4
4) using a mouse-doubleclick activate the datetime entry field as explained above
5) Shift-INS to paste the paste-buffer content
6) ENTER & voila, you are there.
I've implemented a PDF export of a table that has images in the first column. I use the createdCell callback to determine the (x,y) coordinates of the cell and then use doc.addImage() to render the image at the appropriate place.
The problem I have is that the images are actually behind the rendered table if I render them to the correct coordinates. If I shift the x-coordinate left I can see the images are rendered to the doc.
Does anyone know if there is a way to specify the layer index of objects rendered to the PDF, similar to how z-index property works in CSS?
Or is it possible to change the rendering order so that images are rendered on top?
FYI I was wrong to attempt this using callback, this is possible with addPageContent option.
I did not find any information about depth configuration ("z-index").
However, I know that whenever you add something to the page it is in front of all the items already inserted. As if it were an "incremental z-index".
So answering the question: "how to position one element on top of another" we have three solutions:
Just change the order of which element will be inserted on the page.
Create a loop adding all the necessary information (in this case, the table) and in another loop just create the images.
Invert the loop, for example with [a, b, c] = [c, b, a]. So the elements started to be created from the bottom up on the page (if your problem is a conflict between the loops). This case is more boring, more confusing and more difficult, but it may be the solution.
I am trying to capture the pixel color of a specific letter in a font within an iOS app. I'd then use that color in an if/then statement to determine the next action of my script. I'm finding no easy way to determine if the color/colors I'm finding are the right ones. Here's my current process: I start recording my inputs and continuously click around the letter. I end up with something like touchdown(123,456). I change that to alert(getColor(123,456)) and run, which produces a popup that tells me the color such as 3094841 (not sure why the colors are in numeric format, but they are). I do this for each touchdown line that is captured. The problem is, I don't know an easy way to determine which color is the small letter I'm trying to tap.
Is there a lua function that will capture and display a range of colors between 2 points? If there were, I could see the commonality of all of the colors within the 2 points and make at least an educated guess as to which is the color in the font. Or even more useful - is there a tool I can use to type in the color I'm getting back and have it display the corresponding color, so I can compare them. That'd be the easiest. Hope this makes sense. Any help would be awesome. In case it matters, I'm using Autotouch 8 on an iPhone 5.
TIA
I use this function often in my games.
I find the easiest way to get a color you want to execute every single time is to take a snap of the screen you're checking and then use the helper on getColor(x, y)
And you can use this to alert your color.
local color = getColor(x, y)
alert(color)
-- You can also use:
log(color)--this one keeps it in your log in case you can write it down immediately.
To use this in an if/then statement
function = namedfunction()
local color = getColor(x, y)
if color == YOURCOLOR then
else
end
end
namedfunction();
Note that I have the iPhone 5 iOS 8.3 and I have the most recent AutoTouch from Cydia. If you don't have the helper when you're scripting it might be worth it to check if Cydia offers a capatable version.
Edit: I am running version 3.5.3-8 of Autotouch.
I'm working on a site prototype that has many rollover images in the navigation. Each image is unique, but the rollover and rollout code is identical. I'm trying to create a single symbol that can be used for all of the rollovers, but need some help figuring this out, as it will significantly speed up my work.
I think the pseudocode would work like this
Create a symbol that contains a default rollover image.
In the symbol, add the rollover and rollout code. This adjusts transparency from 0 -> 100 and back.
Create instances of the symbol over each item in the nav.
For each instance, set a variable containing the name of the rollover image to be used.
In that symbol instance, get the variable value.
In that symbol instance, use the image name in the variable to replace the default image.
Question: How do I make step 4-6 work? I have 1-3 working smoothly.
Update: I have #6 solved
Images are all managed by the CSS background-image property rather than the old-school <img src=...>. So to set an image for an element, the syntax is:
$(sym.lookupSelector("[ElementName]")).css('background-image', [image]);
And there's a second part, which is getting [image] right.
Use the default relative URL for Edge images: images/[image]
Use standard syntax for CSS background-image: url(images/[image])
P.S. My last dev work was waaaaay back with Director, PHP and ColdFusion. I still get basic principles such as using functions, objects, instances, inheritance etc, but the language has changed. And I have very very little experience with the DOM.
Appendix: How I'm Doing This Manually
There's a background image of the nav showing all of the unselected states
Each item in the nav has a corresponding rollover image, in a series of elements layered on top of nav element. Each rollover has opacity initially set to 0%.
Each image element has rollover, rollout and click triggers. Rollover and rollout triggers are identical for each. There's also a little more code with rollout that provides a quick fade. This means lots of copying identical code. I hate to think about having to change any part of that code.
I came to the same conclusions as yours.
Steps 4-5 I did this way: when I create the symbol instance I give it a special name, like "button_image1".
Then in the code you can check this property doing:
var symbolElement = sym.getSymbolElement();
var id = symbolElement.attr("id")
var tokens = id.split("_");
var image = tokens[1];
And set the right image as background.
You can put this code on the creation_complete event of the symbol.