Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Change jpg image exif orientation value
Message
 
To
09/08/2016 12:38:40
General information
Forum:
Visual FoxPro
Category:
Pictures and Image processing
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 8.1
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01639240
Message ID:
01639253
Views:
81
This is perfect. Thanks so much Antonio!


>>I need to change the exif orientation value in a JPG image.
>>
>>Anybody have a code example on how to do this?
>>
>>I found this: http://www.news2news.com/vfp/?example=461
>>
>>But the site doesn't work for me (pay for membership to get code) and I'm not getting any replies to email I send.
>
>Start by using / installing the GDIPlusX library at http://vfpx.codeplex.com/wikipage?title=GDIPlusX.
>
>After issuing System.app, you are set to go (no error trapping, nothing fancy, just something to get you started):
>
>
>LOCAL ExifTargetOrientation AS Integer
>
>* the pretended orientation (left - bottom)
>m.ExifTargetOrientation = 0h0800
>
>LOCAL IdExifOrientation AS Integer
>
>m.IdExifOrientation = 0x112
>
>LOCAL JPEGImage
>
>* get a JPEG image from disk
>JPEGImage = _Screen.System.Drawing.Image.Fromfile(GETFILE("jpg"))
>
>LOCAL LoopProperties AS Integer
>LOCAL ExifOrientation AS Integer
>
>m.ExifOrientation = 0
>
>* locate EXIF orientation setting
>FOR m.LoopProperties = 1 TO m.JPEGImage.PropertyItems.Count
>
>	* found it? get its index
>	IF m.JPEGImage.PropertyIdList(m.LoopProperties) = m.IdExifOrientation
>		m.ExifOrientation = m.LoopProperties
>		EXIT
>	ENDIF
>
>ENDFOR
>
>* not found...
>IF m.ExifOrientation = 0
>	MESSAGEBOX("No EXIF orientation settings found in the image")
>	RETURN
>ENDIF
>
>LOCAL ExifProperty
>
>* get the orientation property
>m.ExifProperty = m.JPEGImage.GetPropertyItem(m.IdExifOrientation)
>
>* and check its value - if already set as the target orientation, just leave as it is
>IF m.ExifProperty.Value = m.ExifTargetOrientation
>	MESSAGEBOX("EXIF orientation already set to " + TRANSFORM(m.ExifTargetOrientation))
>	RETURN
>ENDIF
>
>* set the target orientation setting and put the property back in the image
>m.ExifProperty.Value = m.ExifTargetOrientation
>m.JPEGImage.SetPropertyItem(m.ExifProperty)
>
>* save the image
>m.JPEGImage.Save(PUTFILE("Reoriented:","reoriented.jpg","jpg"), _Screen.System.Drawing.Imaging.ImageFormat.Jpeg)
>
Brandon Harker
Sebae Data Solutions
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform