UtilImageCompressImage(String, String, ImageFormat, Int32) Method
Compresses a image file to the specified filesize and saves the compressed image to disk.
Namespace: DevCase.Core.Media.GraphicsAssembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
public static void CompressImage(
string srcFilepath,
string dstFilepath,
ImageFormat newImageFormat,
int newFileSize
)
Public Shared Sub CompressImage (
srcFilepath As String,
dstFilepath As String,
newImageFormat As ImageFormat,
newFileSize As Integer
)
Dim srcFilepath As String
Dim dstFilepath As String
Dim newImageFormat As ImageFormat
Dim newFileSize As Integer
UtilImage.CompressImage(srcFilepath,
dstFilepath, newImageFormat, newFileSize)
public:
static void CompressImage(
String^ srcFilepath,
String^ dstFilepath,
ImageFormat^ newImageFormat,
int newFileSize
)
static member CompressImage :
srcFilepath : string *
dstFilepath : string *
newImageFormat : ImageFormat *
newFileSize : int -> unit
No code example is currently available or this language may not be supported.
Parameters
- srcFilepath String
-
The source image filepath.
- dstFilepath String
-
The target image filepath.
- newImageFormat ImageFormat
-
The target image format.
- newFileSize Int32
-
The target filesize, in bytes.
This is a code example that compress all JPG files in the specified directory.
No code example is currently available or this language may not be supported.
' JPEG image files.
Dim imageFiles As IEnumerable(Of FileInfo) = New DirectoryInfo("C:\Images").EnumerateFiles("*.jpg", SearchOption.TopDirectoryOnly)
Dim compressedSize = 1048576 ' 1 Megabyte
For Each imgFile As FileInfo In imageFiles
UtilImage.CompressImage(imgFile.FullName, Path.ChangeExtension(imgFile.FullName, "compressed.jpg"), ImageFormat.Jpeg, compressedSize)
Console.WriteLine($"Image Compressed: {imgFile.FullName}")
'' Send old JPEG image to Recycle Bin.
' My.Computer.FileSystem.DeleteFile(imgFile.FullName, FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.SendToRecycleBin)
Next imgFile
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.