The first parameter is the executable. You may need the full path if it is not in the system path. The second parameter are parameters to send to the first.
what does s.result say?
is sips installed? and if so, is it on the “path”?
assuming this is OSX, since sips is an OSX utility
here is code I use to locate SIPS
//
// Look for SIPS ... required for GIF and TIFF output
//
For x=0 To 1
flag=False
f=Volume(0)
If f=Nil Then Exit For
If x=1 Then f=f.child("developer")
If f=Nil Then Continue
//
f=f.child("usr")
If f=Nil Then Continue
If Not f.exists Then Continue
//
f=f.child("bin")
If f=Nil Then Continue
If Not f.exists Then Continue
//
f=f.child("sips")
If f=Nil Then Continue
flag=f.exists
//
If flag Then Exit For
Next x
and some code to call it
s="sips -s format "+sips_format+" "+temp_file.shellpath+" --out "+xfile.shellPath
//
sh.Mode = 0
sh.Execute s
app.DoEvents
If InStr(sh.Result,"command not found")>0 Then
Beep
myMsgBox "SIPS Not Found^The Image Conversion utility 'SIPS'^was not located on this computer.^^This is required for GIF and TIFF file^formats.",16
End If
I have never installed sips onto Mavericks, and had no idea it needed to be installed (I presumed it was part of the OS).
I am simply trying to save an image (preferably as a png), but keep the quality at the absolute maximum.
I was informed that saving as a jpg with 100 quality still produced a lower quality image than a png using sips?
If sips has to be installed on the user’s machine just to save as a high quality png, then I will have to settle for a lower quality jpg
and I seriously doubt that SIP will save a higher quality version of a PNG, the the normal Xojo SavePicture as PNG does.
Yes, a PNG is better quality than a JPG… but if you start with a JPG and save as a PNG, you do not IMPROVE the quality, while starting with a PNG and saving as a JPG will usually lower the quality (usually,not always)
The only reason by app uses SIPS at all is to save pics as GIF or TIF, all JPG and PNG processing is done with built in XOJO features
That is talking about RESIZING an image… and yeah. SIPS probably does a better job…
You were talking about just SAVING it… there SIPS will offer nothing extra.
After adding the necessary dim statements etc. I ran your code Dave, and nothing at all happened - just an empty window
I can’t seem to find the full path?
The first parameter is the executable. You may need the full path if it is not in the system path. The second parameter are parameters to send to the first.[/quote]
After reading the docs here, I understand it can be done all on one line, but the above is preferred as if you have a space in the path to the executable, or the executable itself has a space, that will throw things off. For example:
s.Execute("/Users/Jeremy C/bin/sips", "-s format ...")
will work, but
s.Execute("/Users/Jeremy C/bin/sips -s format ...")
Ok - I am going to have to give up on this.
I don’t understand this at all, and I even tried to include what I can gather should be the full path - but I still get NO png
Dim s As New Shell
s.mode = 0
s.Execute ("developer/usr/bin/sips", " -s format png -Z 256 newpic --out ~/Desktop/256.png")
Thanks for trying to help, but I will stick with crappy version of png.
Did you examine the SH.RESULT value? it will contain any error message…
plus… I believe your syntax is wrong
s.Execute (“sips”, " -s format png -Z 256 “+newpic+” --out ~/Desktop/256.png")
where newpic is a variable with the path of the picture to convert (newpic.nativepath perhaps)
[code]// 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)
// ASSOCIATE F WITH THE FULL OUTPUT PATH AND NAME
f = SpecialFolder.Desktop.child("512.png")
// SAVE THE CONTENT OF THE PICTURE OBJECT CALLED NEWPIC AS A JPG TO THE OUTPUT PATH
//newpic.save(f, picture.SaveAsPNG)[/code]
This code doesn’t:
Dim s As New Shell
s.mode = 0
s.Execute ("sips", " -s format png -Z 512 newpic --out ~/Desktop/512.png")
Dave - I was paying attention, but I don’t understand what is being said
In the terminal I was told that sips is in the following path:
usr/bin/sips
I couldn’t do as you suggested because:
A) I have no idea how to even check sh.RESULTS
B) I do not know the path to the image because it is an image which gets dropped onto Canvas1 via the code below:
pic = picture.open(obj.FolderItem)
I am not ignoring your advice - I simply do not understand it, as I am still getting to grips with dropping images onto a canvas and storing them as picture objects. Then at the same time, I get problems with shell scripting which I no NOTHING about.
I will try and work out how to check sh.RESULTS now.
Seriously Dave - please don’t be annoyed but I have to give up on this.
Your code produces numerous Does not Exist Errors (for me at least), so I can’t even check sh.Result, and I still cannot work out the path to newpic.
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.
I really appreciate your patience and attempts to help but this is just WAY beyond me at the moment.