Skip to content

Commit

Permalink
Increase max size of resized stickers
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanHahn-Signal committed Feb 24, 2022
1 parent f58d133 commit b1e48dc
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions sticker-creator/preload.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019-2021 Signal Messenger, LLC
// Copyright 2019-2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only

/* global window */
Expand Down Expand Up @@ -28,8 +28,7 @@ const { createSetting } = require('../ts/util/preload');
const STICKER_SIZE = 512;
const MIN_STICKER_DIMENSION = 10;
const MAX_STICKER_DIMENSION = STICKER_SIZE;
const MAX_WEBP_STICKER_BYTE_LENGTH = 100 * 1024;
const MAX_ANIMATED_STICKER_BYTE_LENGTH = 300 * 1024;
const MAX_STICKER_BYTE_LENGTH = 300 * 1024;

window.ROOT_PATH = window.location.href.startsWith('file') ? '../../' : '/';
window.getEnvironment = getEnvironment;
Expand Down Expand Up @@ -101,7 +100,7 @@ window.processStickerImage = async path => {
// [0]: https://github.com/lovell/sharp/issues/2375
const animatedPngDataIfExists = getAnimatedPngDataIfExists(imgBuffer);
if (animatedPngDataIfExists) {
if (imgBuffer.byteLength > MAX_ANIMATED_STICKER_BYTE_LENGTH) {
if (imgBuffer.byteLength > MAX_STICKER_BYTE_LENGTH) {
throw processStickerError(
'Sticker file was too large',
'StickerCreator--Toasts--tooLarge'
Expand Down Expand Up @@ -144,7 +143,7 @@ window.processStickerImage = async path => {
})
.webp()
.toBuffer();
if (processedBuffer.byteLength > MAX_WEBP_STICKER_BYTE_LENGTH) {
if (processedBuffer.byteLength > MAX_STICKER_BYTE_LENGTH) {
throw processStickerError(
'Sticker file was too large',
'StickerCreator--Toasts--tooLarge'
Expand Down

0 comments on commit b1e48dc

Please sign in to comment.