Platforms to show: All Mac Windows Linux Cross-Platform

Back to JPEGExporterMBS class.

JPEGExporterMBS.Export

Type Topic Plugin Version macOS Windows Linux iOS Targets
method JPEG MBS Images Plugin ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Exports the picture.
Example
dim g as FolderItem
dim ji as JPEGImporterMBS
dim je as JPEGExporterMBS
dim f as FolderItem
dim m as MemoryBlock

// this code copies a JPG: CMYK or RGB

// import it
g=SpecialFolder.Desktop.Child("PICT1533.JPG")
ji=new JPEGImporterMBS
ji.File=g
ji.AllowDamaged=true
ji.CMYK=true // if it is cmyk
if ji.InitJPEG then
do
loop until ji.LoopJPEG<>0
ji.FinishJPEG
end if

// export it
f=SpecialFolder.Desktop.child("PICT1533 copy.JPG")
je=new JPEGExporterMBS
je.File=f
je.Quality=75

if ji.CMYK then
m=ji.PictureData
je.ExportCMYK m, ji.Width, ji.Height, ji.Width*4
else
je.Picture=ji.Picture
je.Export
end if

This methods saves 32bit pictures to a file using JPEG Compression. Using the properties of the class you can specify the quality in range between 0 and 100%

This method is not depending on any library! It works without QuickTime even on System 7, but as it contains everything needed this method is around 100 KB big!

You may use the function picture.bitmap to make sure that the picture is a bitmap, because this function works only for bitmap pictures.

This method uses the YieldTicks property and may yield time to other threads.

Some examples using this method:

JPEGExporterMBS.ExportCMYK(data as memoryblock, width as UInt32, height as UInt32, rowbytes as UInt32)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method JPEG MBS Images Plugin 3.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Exports a picture from CMYK data in a memoryblock.
Example
dim g as FolderItem
dim ji as JPEGImporterMBS
dim je as JPEGExporterMBS
dim f as FolderItem
dim m as MemoryBlock

// import it
g=getOpenFolderItem("image/jpeg")
ji=new JPEGImporterMBS
ji.File=g
ji.AllowDamaged=true
ji.ImportCMYK

m=ji.PictureData

// export it
f=SpecialFolder.Desktop.child("test.jpg")
je=new JPEGExporterMBS
je.HorizontalResolution=300
je.VerticalResolution=300
je.ResolutionUnit=1
je.File=f
je.Quality=75
je.ExportCMYK m, ji.Width, ji.Height, ji.Width*4

This methods saves 32bit CMYK pictures to a file using JPEG Compression. Using the properties of the class you can specify the quality in range between 0 and 100%

This method is not depending on any library! It works without QuickTime even on System 7, but as it contains everything needed this method is around 100 KB big!

The picture must be in the format that one byte is used for each channel and the channels are ordered in memory in Cyan, Magenta, Yellow and Black.
If rowbytes is 0, the plugin uses width*4 for rowbytes.

This method uses the YieldTicks property and may yield time to other threads.

Some examples using this method:

JPEGExporterMBS.ExportGray

Type Topic Plugin Version macOS Windows Linux iOS Targets
method JPEG MBS Images Plugin 12.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Exports an 8 bit grayscale picture.

Same as Export, but writes grayscale picture. The picture from picture property is converted to grayscale internally for this.

See also:

Some examples using this method:

JPEGExporterMBS.ExportGray(data as memoryblock, width as UInt32, height as UInt32, rowbytes as UInt32)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method JPEG MBS Images Plugin 17.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Exports an 8 bit grayscale picture.

Same as Export, but writes grayscale picture using data in memoryblock.
If rowbytes is 0, the plugin uses width for rowbytes.
This method uses the YieldTicks property and may yield time to other threads.

See also:

JPEGExporterMBS.ExportRGB(data as memoryblock, width as UInt32, height as UInt32, rowbytes as UInt32)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method JPEG MBS Images Plugin 8.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Exports a picture from RGB data in a memoryblock.
Example
dim f as FolderItem
dim ji as new JPEGImporterMBS
dim je as new JPEGExporterMBS
dim m as MemoryBlock
dim i,c as Integer

// read jpeg
f=SpecialFolder.Desktop.Child("input.jpg")

ji.Mode=ji.ModeRGB // read RGB to memoryblock
ji.File=f
ji.Import

m=ji.PictureData

// add red
c=m.Size-1
for i=0 to c step 3
m.Byte(i)=255
next

// write jpeg
f=SpecialFolder.Desktop.Child("test.jpg")

je.File=f
je.ExportRGB(m,ji.Width, ji.Height, ji.Width*3)

The memoryblock data must be in the format with bytes in the order RGB.

Some examples using this method:

JPEGExporterMBS.ExportRGBwithRowDataEvent(width as UInt32, height as UInt32, rowbytes as UInt32)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method JPEG MBS Images Plugin 9.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Exports a picture from RGB data in memoryblocks from the GetRowData event.

You need to implement the GetRowData event by subclassing this class.
The memoryblock data must be in the format with bytes in the order RGB.

Some examples using this method:

JPEGExporterMBS.Markers(Index as Integer) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
property JPEG MBS Images Plugin 14.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Additional markers.
Example
dim j as new JPEGExporterMBS

j.Picture = LogoMBS(500)
j.Markers(5) = "Hello World"
j.File = SpecialFolder.Desktop.Child("test.jpg")
j.Export

// now open jpeg file in text editor and you see hello world near beginning

Index from 0 to 15.
Index zero is used for JFIF header.
Index one is normally used for EXIF or XMP.
Index 13 is often used for Photoshop.

see also
http://www.ozhiker.com/electronics/pjmt/jpeg_info/app_segments.html

You can use this markers to embed a given string in the file. You can encrypt data and store it next to the image as you like.
Of course this will not survive if image is loaded and saved again. But can work as a container to hide data and user sees only image.
(Read and Write computed property)

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


The biggest plugin in space...