[TIMOB-28535] Android: Blob fails to read WebP image file info
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | Medium |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2021-10-20T03:37:25.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | Release 10.2.0 |
| Components | Android |
| Labels | android, blob, mimetype, webp |
| Reporter | Joshua Quick |
| Assignee | Joshua Quick |
| Created | 2021-09-15T21:09:30.000+0000 |
| Updated | 2021-10-20T03:37:25.000+0000 |
Description
*Summary:*
When loading a WebP image via a Titanium Copy attached "TiLogoOpaque.webp" to project folder
Notice image fails to display. (This is because
Notice displayed "Image Size" wrongly reads:
Notice displayed "MimeType" wrongly reads:
Blob, the following Blob APIs fail to read WebP information.
* width, height, uprightWidth, uprightHeight: Wrongly returns zero.
* mimeType: Wrongly returns "audio/x-wav"
* imageAs*() and imageWith*() methods: Always return null.
*Note:*
An ImageView can display a blob's WebP image just fine. This is just an issue with how a Blob fetches the image's information which may be needed to size/position an image view correctly.
*Steps to reproduce:*
Copy attached "TiLogoOpaque.webp" to project folder Resources/assets/images
Build and run the below code on Android.
Notice image fails to display. (This is because imageAsThumbnail() returned null.)
Notice displayed "Image Size" wrongly reads: 0x0
Notice displayed "MimeType" wrongly reads: audio/x-wav
const file = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, "assets/images/TiLogoOpaque.webp");
const blob = file.read();
const window = Ti.UI.createWindow();
window.add(Ti.UI.createImageView({
image: blob.imageAsThumbnail(320, 1, 64),
}));
window.add(Ti.UI.createLabel({
text: Image Size: ${blob.uprightWidth}x${blob.uprightHeight}\nMime-Type: ${blob.mimeType},
backgroundColor: OS_IOS ? "white" : "?android:attr/colorBackground",
bottom: "30dp",
}));
window.open();
Attachments
| File | Date | Size |
|---|---|---|
| TiLogoOpaque.webp | 2021-09-15T21:03:03.000+0000 | 54960 |
PR (titanium_mobile): https://github.com/appcelerator/titanium_mobile/pull/13069