The code below is looking fine, but can it be shorter ?
// b. Save the image in the Destination folder
// [2022-02-23] Select Structure added (was saving as .jpeg)
Select Case File_Extension
Case "gif"
Resized_Pict.Save(gDestination_FI.Child(Child_Name), Picture.SaveAsGIF)
Case "jpg"
Resized_Pict.Save(gDestination_FI.Child(Child_Name), Picture.SaveAsJPEG)
Case "png"
Resized_Pict.Save(gDestination_FI.Child(Child_Name), Picture.Sa
Case "tif"
Resized_Pict.Save(gDestination_FI.Child(Child_Name), Picture.SaveAsTIFF)
End Select
File_Extension is a text string that came from a user selection PopupMenu.
The code works fine, but not with Xojo 2015r1/El Capitan where the gif export fails. Preview is able to export as .gif as well as High Sierra/Xojo 2021r2.1 (runnin in the IDE).
var okToExport as boolean var exportFormat as Picture.Formats select case file_extension case "gif" exportFormat=Picture.Formats.GIF okToExport=true .....//all other cases end select if okToExport and Picture.IsExportFormatSupported(exportFormat) then Resized_pict.save(gDestination_FI.child(child_name), exportFormat) end if
Var okToExport As Boolean
Var exportFormat As Picture.Formats
Select Case file_extension
Case "gif"
exportFormat=Picture.Formats.GIF
okToExport=True // .....
//all other cases
End Select
If okToExport And Picture.IsExportFormatSupported(exportFormat) Then
Resized_pict.save(gDestination_FI.child(child_name), exportFormat)
End If
It gets more lines, and you add a test about if the export format is available… The LR says these format are available for Desktop. That was the reason why I do not tested them.
var exportFormats() as Picture.Formats=Array(Picture.Formats.GIF, ....)
var exportNames() as string=Array("gif", ...)
var index as integer=exportNames.indexOf(file_extension)
if index>-1 then
Resized_pict.save(gDestination_FI.child(child_name), exportFormats(index))
end if