Generate blurHash for outgoing link previews
This commit is contained in:
parent
b93164a8c0
commit
3a94d2c75e
1 changed files with 9 additions and 0 deletions
|
@ -15,6 +15,7 @@ type GetLinkPreviewImageResult = {
|
||||||
contentType: string;
|
contentType: string;
|
||||||
width?: number;
|
width?: number;
|
||||||
height?: number;
|
height?: number;
|
||||||
|
blurHash: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type GetLinkPreviewResult = {
|
type GetLinkPreviewResult = {
|
||||||
|
@ -3758,6 +3759,11 @@ Whisper.ConversationView = Whisper.View.extend({
|
||||||
data,
|
data,
|
||||||
size: data.byteLength,
|
size: data.byteLength,
|
||||||
contentType: 'image/jpeg',
|
contentType: 'image/jpeg',
|
||||||
|
blurHash: await window.imageToBlurHash(
|
||||||
|
new Blob([data], {
|
||||||
|
type: 'image/jpeg',
|
||||||
|
})
|
||||||
|
),
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const errorString = error && error.stack ? error.stack : error;
|
const errorString = error && error.stack ? error.stack : error;
|
||||||
|
@ -3833,6 +3839,8 @@ Whisper.ConversationView = Whisper.View.extend({
|
||||||
const data = await this.arrayBufferFromFile(withBlob.file);
|
const data = await this.arrayBufferFromFile(withBlob.file);
|
||||||
objectUrl = URL.createObjectURL(withBlob.file);
|
objectUrl = URL.createObjectURL(withBlob.file);
|
||||||
|
|
||||||
|
const blurHash = await window.imageToBlurHash(withBlob.file);
|
||||||
|
|
||||||
const dimensions = await VisualAttachment.getImageDimensions({
|
const dimensions = await VisualAttachment.getImageDimensions({
|
||||||
objectUrl,
|
objectUrl,
|
||||||
logger: window.log,
|
logger: window.log,
|
||||||
|
@ -3843,6 +3851,7 @@ Whisper.ConversationView = Whisper.View.extend({
|
||||||
size: data.byteLength,
|
size: data.byteLength,
|
||||||
...dimensions,
|
...dimensions,
|
||||||
contentType: withBlob.file.type,
|
contentType: withBlob.file.type,
|
||||||
|
blurHash,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// We still want to show the preview if we failed to get an image
|
// We still want to show the preview if we failed to get an image
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue