Author |
Topic |
|
Dany
59 Posts |
Posted - Dec 11 2018 : 07:01:32
|
Hello;
I found that every photo I take using Galaxy's cameras (S5 to S9 tested) are being rotated, if the photos are vertical. All other standar applications are reading those images in the correct orientation.
I testesd using my own project, and a few test projects that come as examples in ImageEn. For example, I added a few lines in the RotateTool project, but it still rotates the image:
procedure TForm1.btnOpenClick(Sender: TObject); var
sFilename: string;
begin
sFilename := ImageEnView1.IO.ExecuteOpenDialog();
if sFilename <> '' then
begin
ImageEnView1.IO.Params.TIFF_EnableAdjustOrientation := False; ///////// I added this
ImageEnView1.IO.Params.TIFF_Orientation := _exoCorrectOrientation; ///////// I added this
ImageEnView1.Proc.ClearUndo();
ImageEnView1.MouseInteract := []; // Reset the rotation tool
ImageEnView1.IO.LoadFromFile( sFilename );
ControlChange(nil);
ImageEnView1.MouseInteract := [ miRotateTool ];
lblInfo.Enabled := True;
// Focus the TImageEnView, so keyboard events are handled
ImageEnView1.SetFocus();
end;
end;
Any idea about how to fix this problem?. I attached an example image.
Thank you!
attach/Dany/2018121173410_20181128_221917.jpg |
|
rmklever
Norway
51 Posts |
Posted - Dec 11 2018 : 10:05:14
|
Hi Dany,
Try using
ImageEnView1.Params.EnableAdjustOrientation:= True;
You are setting autoRotation for tiff files only... I belive.
Hope this helps.
Roy M Klever Klever on Delphi - www.rmklever.com |
|
|
Dany
59 Posts |
Posted - Dec 11 2018 : 13:43:09
|
Hello Roy, I tried everithing. Also, we have to considere that this images are readed wiht other editor by default in correct orientation. |
|
|
rmklever
Norway
51 Posts |
Posted - Dec 11 2018 : 15:56:34
|
Hi Dany,
I am a little confused, what exactly is it you want to happen.
If you want the photo to be auto rotated you set:
imgView.IO.Params.EnableAdjustOrientation:= True;
and if no rotation is wanted:
imgView.IO.Params.EnableAdjustOrientation:= False;
At least that is what happens when I try it in my app.
Roy M Klever Klever on Delphi - www.rmklever.com |
|
|
Dany
59 Posts |
Posted - Dec 12 2018 : 06:53:24
|
Than you Roy;
My extact case is that I am receiving each file as a stream, directly form the celphone, using tethering. So I do:
procedure TImgCollection.RecibeDeMovil(const AStream: TMemoryStream; const sFileName: string);
var
MB: TIEMultiBitmap;
sFileExts, s: string;
iPos, iTot, i: integer;
begin
MB := TIEMultiBitmap.Create;
try
MB.ParamsEnabled := True;
MB.Read(AStream);
iTot := MB.Count;
for i := 0 to iTot-1 do
begin
MB.Params[i].EnableAdjustOrientation := True;
MB.Resample(i, FTamaMax, FTamaMax, rfFastLinear, True, True);
end;
MB.Write('myfile.tiff');
finally
MB.Free;
end;
end;
I do this way because I can receive a tiff in the stream, but I have to resample each image before saving. Maybe the problem is MB does not have a chance to auto-orient because the image is loaded before, but I don't see a command for auto-rotating after load.
But I cannot get the image in the correct orientation. |
|
|
xequte
38616 Posts |
Posted - Dec 12 2018 : 09:04:24
|
Hi
Unfortunately I am out of the office until after Christmas, so I cannot test this directly.
The EXIF orientation of this image is _exoNeeds90RotateCW (6).
https://www.imageen.com/help/TIOParams.EXIF_Orientation.html
So if EnableAdjustOrientation is true, then ImageEn will rotate it 90 degrees when displayed in a TImageEnView or TImageEnMView.
(Also, EnableAdjustOrientation must be enabled BEFORE loading).
EnableAdjustOrientation does not actually modify the file, please see:
https://www.imageen.com/help/TIOParams.EnableAdjustOrientation.html
You would be better to read the EXIF_Orientation yourself and rotate the image appropriately. Generally only _exoNeeds180Rotate, exoNeeds90RotateCW and _exoNeeds270RotateCW are needed.
Nigel Xequte Software www.imageen.com |
|
|
Dany
59 Posts |
Posted - Dec 12 2018 : 09:53:51
|
Thank you; I tried to modify my code in this way:
MB.ParamsEnabled := True; MB.Read(AStream); iTot := MB.Count; for i := 0 to iTot-1 do begin case MB.Params[i].EXIF_Orientation of _exoNeeds180Rotate: MB.Rotate(i, 180); _exoNeeds90RotateCW: MB.Rotate(i, 90); _exoNeeds270RotateCW: MB.Rotate(i, 270); end;
But I see EXIF_Orientation is always 0, for all the images. Do I missed something else? |
|
|
w2m
USA
1990 Posts |
Posted - Dec 12 2018 : 10:01:53
|
Try setting MB.Params[i].EnableAdjustOrientation to True before reading the stream.
Bill Miller Adirondack Software & Graphics Email: w2m@hughes.net EBook: http://www.imageen.com/ebook/ Custom Commercial ImageEn Development |
|
|
Dany
59 Posts |
Posted - Dec 12 2018 : 10:04:44
|
Before reading the stream there are no items in MB. |
|
|
w2m
USA
1990 Posts |
Posted - Dec 12 2018 : 10:31:08
|
Try setting the MParams.EnableAdjustOrientation when Reading:
var MB: TIEMultiBitmap; sFileExts, s: string; iPos, iTot, i: integer; AStream: TMemoryStream; MParams: TIOMultiParams; begin MB.ParamsEnabled := True; MParams.EnableAdjustOrientation := True; MB.Read(AStream, MParams); iTot := MB.Count; for i := 0 to iTot - 1 do begin case MB.Params[i].EXIF_Orientation of _exoNeeds180Rotate: MB.Rotate(i, 180); _exoNeeds90RotateCW: MB.Rotate(i, 90); _exoNeeds270RotateCW: MB.Rotate(i, 270); end; end;
Bill Miller Adirondack Software & Graphics Email: w2m@hughes.net EBook: http://www.imageen.com/ebook/ Custom Commercial ImageEn Development |
|
|
Dany
59 Posts |
Posted - Dec 12 2018 : 10:48:22
|
The Read method does not accept a TIOParams as a parameter. |
|
|
w2m
USA
1990 Posts |
Posted - Dec 12 2018 : 10:52:17
|
Sorry, Try TIOMultiParams. Look at the help file:
function Read(Stream: TStream; FileType: TIOFileType = ioUnknown; IOParams: TIOMultiParams = nil): boolean; overload;
Bill Miller Adirondack Software & Graphics Email: w2m@hughes.net EBook: http://www.imageen.com/ebook/ Custom Commercial ImageEn Development |
|
|
Dany
59 Posts |
Posted - Dec 12 2018 : 12:42:04
|
OK, I did:
// Levanto los parámetros desde el stream IOP := TIOMultiParams.Create; IOP.Read(AStream); iTot := IOP.Count; for i := 0 to iTot-1 do IOP.Params[i].EnableAdjustOrientation := True; // Formato aceptado .... MB := TIEMultiBitmap.Create; try AStream.Position := 0; MB.Read(AStream, ioUnknown, IOP);
But didn't work, images are still with wrong orientation. |
|
|
w2m
USA
1990 Posts |
Posted - Dec 12 2018 : 12:51:24
|
You are still reading the stream before setting EnableAdjustOrientation to true. Somehow you have to set EnableAdjustOrientation to true before reading the stream, otherwise the procedure has no way to know if the orientation should be adjusted. I am not an expert with this particular function because I have never used it. Anyway, Nigel can probably get you on track.
I did spot this which may or may not help: (it is supposed to work with TIEMultiBitmap)
TIEImageEnGlobalSettings.IOParamDefaults
Declaration
property IOParamDefaults: TIOParamDefaults;
Description
Sets some default properties when intializing TIOParams objects.
Some properties of TIOParams objects affect the way images are loaded. It can be useful to set these globals, which will affect the loading of all images in TImageEnView, TImageEnMView, TImageEnFolderMView, TIEBitmap and TIEMultiBitmap.
EnableAdjustOrientation EnableAdjustOrientation, JPEG_EnableAdjustOrientation and TIFF_EnableAdjustOrientation False RAW_AutoAdjustColors RAW_AutoAdjustColors False RAW_HalfSize RAW_HalfSize False RAW_GetEmbeddedJpeg RAW_GetEmbeddedJpeg False RAW_Interpolation RAW_Interpolation ieRAWInterpolationLinear RAW_QuickInterpolate RAW_QuickInterpolate True RAW_UseAutoWB RAW_UseAutoWB False RAW_UseCameraWB RAW_UseCameraWB False JPEG_DCTMethod JPEG_DCTMethod ioJPEG_ISLOW JPEG_Quality * JPEG_Quality, TIFF_JPEGQuality, DICOM_JPEGQuality 80 JPEG_Scale JPEG_Scale ioJPEG_FULLSIZE PSD_LoadLayers PSD_LoadLayers False
Note: JPEG_Quality only affects saving, not loading, but is included because of its frequent usage
Example
// For all loading, automatically rotate images to their correct orientation IEGlobalSettings().IOParamDefaults.EnableAdjustOrientation := True
// Improve the colors of Raw camera images added to a TIEMultiBitmap IEGlobalSettings().IOParamDefaults.RAW_AutoAdjustColors := True; IEGlobalSettings().IOParamDefaults.RAW_UseAutoWB := True; IEGlobalSettings().IOParamDefaults.RAW_UseCameraWB := True; MyMultiBitmap.FillFromDirectory( 'E:\DCIM\' );
// Faster loading for all Camera Raw images IEGlobalSettings().IOParamDefaults.RAW_HalfSize := True; IEGlobalSettings().IOParamDefaults.RAW_GetEmbeddedJpeg := True;
Bill Miller Adirondack Software & Graphics Email: w2m@hughes.net EBook: http://www.imageen.com/ebook/ Custom Commercial ImageEn Development |
|
|
Dany
59 Posts |
Posted - Dec 12 2018 : 13:24:17
|
Yeahhh Bill, thank you! this line did the trick:
IEGlobalSettings().IOParamDefaults.EnableAdjustOrientation := True
Many thanks !!! |
|
|
xequte
38616 Posts |
Posted - Dec 12 2018 : 19:31:12
|
Thanks Bill
Nigel Xequte Software www.imageen.com
|
|
|
|
Topic |
|