[quote=105109:@Richard Summers]I am actually starting to get so angry over this ridiculous problem that I am starting to feel really ill.
I am way out of my depth here, and know when to quit.[/quote]
Richard,
I know you are ambitious and seldom give up before you understand fully what you set yourself to achieve. But sometimes, a break is beneficial. Does not mean you have to give up forever with using sips. Just that for today, it does not work. If Xojo resize works, maybe that is sufficient for what you wanted to do originally ?
Michel - I totally understand, and agree with you.
I am annoyed because even if I took a week off, I still wouldn’t understand it when I came back.
Due to my lack of understanding - I am now stuck with a method of achieving the end result which is less than satisfactory.
It seems pointless to save a resized image which will look C R A P, therefore I have to forget the idea completely.
I will never settle for second best - if I can’t do something properly, I would rather not do it.
I do understand what you are saying though, and appreciate you trying to help
I will move on to learning something new, which hopefully makes more sense to me.
Thanks
What the shell does is to execute the same code as what could be typed into the Terminal utility.
So to understand better how a shell command works, I usually test it first with Terminal, before doing a shell with it.
That is exactly what I did. Follow exactly and you will be able to generate a sized down version of the picture.
Get from Examples Projects/Graphics and multimedia/DragPicture the picture Studebaker.jpg and copy it to your desktop
Launch Terminal from the Applications/Utilities folder
Type cd /Users/<yourusername>/Desktop and enter. Your user name appears when you look in Macintosh HD, in the folder called Users.
Your prompt will end as Desktop $
copy and paste this into the Terminal window :
sips -s format png -Z 100 Studebaker.jpg --out stud_100.png
Then press Enter. You do not need the path to sips, as OS X knows where to find it.
Now I tested this and if you follow exactly the instructions, stud_100.png should appear on your desktop.
To adapt this to your shell, change Studebaker.jpg to whatever the shellpath is to your source file, and stud_100.png to whatever the output file shellpath is. The 100 stands for the size of the picture.
Thanks Michel,
I appreciate you taking the time to go through those steps for me!
I did as you advised and it worked perfectly.
I am now trying to follow your advice regarding getting this to work in my project.
The trouble I have is I do not know the path to the source image, as the source image is the image which gets dropped onto canvas 1.
Here is the code so far in the Canvas1 DropObject event:
[code]// DEFINE VARIABLES
dim pic, newpic as picture
// CHECK IF AN IMAGE WAS DROPPED ONTO THE CANVAS
if obj.FolderItemAvailable then
// ATTACH THE DROPPED IMAGE TO THE PICTURE OBJECT CALLED PIC
pic = picture.open(obj.FolderItem)
// RESIZE TO 512 X 512 AND SAVE
// CREATE A NEW 512 X 512 PICTURE OBJECT CALLED NEWPIC
newpic = new picture(512,512,32)
// DRAW PIC AT THE NEW SIZE INTO THE PICTURE OBJECT CALLED NEWPIC
newpic.graphics.drawpicture(pic, 0,0,512,512, 0,0,pic.width,pic.height)
// RESIZE AND SAVE THE IMAGE
Dim s As New Shell
s.mode = 0
s.Execute (sips -s format png -Z 512 UNKNOWNPATH --out 512.png)[/code]
The only problem I seem to have now is how to find the full shellpath to the source image???
Michel - with all due respect - the line of code you kindly provided above, means absolutely nothing to me
I understand that obj.FolderItem refers to the dropped image, but I still have no idea how to find out it’s full shellpath??? This is the very same problem that I have had since the very start.
How on earth do I get the full path to something dropped onto a canvas by the user?
Sorry if I sound dumb, but I have absolutely no idea how to obtain it’s path.
[quote=105181:@Richard Summers]Michel - with all due respect - the line of code you kindly provided above, means absolutely nothing to me
I understand that obj.FolderItem refers to the dropped image, but I still have no idea how to find out it’s full shellpath??? This is the very same problem that I have had since the very start.
How on earth do I get the full path to something dropped onto a canvas by the user?
Sorry if I sound dumb, but I have absolutely no idea how to obtain it’s path.[/quote]
s.Execute("sips -s format png -Z 512 "+obj.FolderItem.shellpath+" --out 512.png")
obj.FolderItem is the FolderItem corresponding to the picture dropped into your app. obj.FolderItem.shellpath is the ShellPath in the FolderItem. ShellPath is the location, the path written the way you would in /Users/Richard/Pictures/mypicture.jpg for instance. Path can also be written in the form of a URL (URLPath) and other forms.
That’s how on Earth (and probably on Mars as well) we get the path to the file pointed to by the FolderItem. That’s all there is to it
I put this code in my app and then dragged an image onto the canvas:
//dim f2 as New folderitem
f2=obj.FolderItem
MsgBox f2.ShellPath
This popped up a MsgBox and gave me the shell path:
I cannot replace “+obj.FolderItem.shellpath+” with the path in the screenshot above, as that refers to my computer, and I have no idea where the user’s image will be coming from???
This still makes absolutely no sense to me?
How can I put in the shell path, when I don’t know what the shell path will be???
I then tried this - to no avail?
Dim s As New Shell
s.mode = 0
s.Execute("sips -s format png -Z 512 f2.shellpath --out 512.png")
dim f2 as New folderitem
f2=obj.FolderItem
Dim s As New Shell
s.mode = 0
s.Execute("sips -s format png -Z 512 "+f2.shellpath+" --out 512.png")
msgbox "F2 is "+f2.shellpath+" RESULT="+sh.result