Platforms to show: All Mac Windows Linux Cross-Platform

/Images/JPEG/Recompress JPEGs


Required plugins for this example: MBS Images Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Images/JPEG/Recompress JPEGs

This example is the version from Sun, 17th Mar 2012.

Project "Recompress JPEGs.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Sub Open() dim ji as New JPEGImporterMBS dim je as New JPEGExporterMBS dim m as MemoryBlock dim f,f1 as FolderItem dim dlg as new OpenDialog dlg.PromptText="Choose a JPEG image to compress it:" dlg.Filter=FileTypes.ImageJpeg f=dlg.ShowModal() if f=nil then return dim origSize as int64 = f.length // import it ji.File=f ji.AllowDamaged=true ji.mode=ji.ModePicture // if it is cmyk, the mode will change ji.Import dim sdlg as new SaveAsDialog sdlg.PromptText="Where to save the new JPEG?" sdlg.Filter=FileTypes.ImageJpeg sdlg.SuggestedFileName = "image.jpg" f=sdlg.ShowModal() if f=nil then return // export it je.File=f je.Quality=70 if ji.Mode = ji.ModeCMYK then m=ji.PictureData je.ExportCMYK m, ji.Width, ji.Height, ji.Width*4 else // is RGB je.Picture=ji.Picture je.Export end if dim comprSize as int64 = f.length if origSize>comprSize then MsgBox "Saved "+str(origSize-comprSize)+" bytes." else MsgBox "New picture is "+str(origSize-comprSize)+" bytes bigger. Maybe you change the quality setting in code?" end if End EventHandler
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
FileTypes
Filetype image/jpeg
End FileTypes
End Project

The items on this page are in the following plugins: MBS Images Plugin.


The biggest plugin in space...