Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-28535] Android: Blob fails to read WebP image file info

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2021-10-20T03:37:25.000+0000
Affected Version/sn/a
Fix Version/sRelease 10.2.0
ComponentsAndroid
Labelsandroid, blob, mimetype, webp
ReporterJoshua Quick
AssigneeJoshua Quick
Created2021-09-15T21:09:30.000+0000
Updated2021-10-20T03:37:25.000+0000

Description

*Summary:* When loading a WebP image via a Titanium 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

FileDateSize
TiLogoOpaque.webp2021-09-15T21:03:03.000+000054960

Comments

  1. Joshua Quick 2021-09-15

    PR (titanium_mobile): https://github.com/appcelerator/titanium_mobile/pull/13069

JSON Source