Reduce JPG size
Posted: Sat Jan 28, 2023 10:54 am
Hello
I found a c# example to reduce the size of jpg files and translated it to x#.
Now i was using it also for my photocollection to reduce discspace and loading time over the web.
Now i have the problem, that photos in portrait format are turned 90 degree . With photos in landscape format it doesnt happend.
With google i found the solution in c# but now i stock to translate the example.
1: How to handle this -> RotateFlipType.
2. Default in the swith ?
3. RotateImageByExifOrientationData = Constructor ?
I know, not much code but hard for me.
Horst
c# source in the zip
I found a c# example to reduce the size of jpg files and translated it to x#.
Now i was using it also for my photocollection to reduce discspace and loading time over the web.
Now i have the problem, that photos in portrait format are turned 90 degree . With photos in landscape format it doesnt happend.
With google i found the solution in c# but now i stock to translate the example.
Code: Select all
CLASS ImageHelper
METHOD RotateFlipType RotateImageByExifOrientationData (oImage AS Image , updateExifData AS LOGIC)
LOCAL orientationId := 0x0112 AS INT
VAR fType := RotateFlipType.RotateNoneFlipNone
IF (oImage:PropertyIdList.Contains(orientationId))
VAR pItem := oImage.GetPropertyItem(orientationId)
fType := GetRotateFlipTypeByExifOrientationData(pItem.Value[0])
IF (fType != RotateFlipType.RotateNoneFlipNone)
oImage.RotateFlip(fType)
// Remove Exif orientation tag (if requested)
IF (updateExifData)
oImage.RemovePropertyItem(orientationId)
ENDIF
ENDIF
ENDIF
RETURN fType
METHOD RotateFlipType GetRotateFlipTypeByExifOrientationData(orientation AS INT)
SWITCH (orientation)
CASE 1 ; // default:?? = otherwise ; RETURN RotateFlipType.RotateNoneFlipNone
CASE 2; RETURN RotateFlipType.RotateNoneFlipX
CASE 3; RETURN RotateFlipType.Rotate180FlipNone
CASE 4; RETURN RotateFlipType.Rotate180FlipX
CASE 5; RETURN RotateFlipType.Rotate90FlipX
CASE 6; RETURN RotateFlipType.Rotate90FlipNone
CASE 7; RETURN RotateFlipType.Rotate270FlipX
CASE 8; RETURN RotateFlipType.Rotate270FlipNone
END SWITCH
END CLASS
2. Default in the swith ?
3. RotateImageByExifOrientationData = Constructor ?
I know, not much code but hard for me.
Horst
c# source in the zip