Skip to content

Commit

Permalink
Merge pull request #16231 from lichess-org/webp
Browse files Browse the repository at this point in the history
always request webp from picfit
  • Loading branch information
ornicar authored Oct 17, 2024
2 parents ce1414d + a26e4d3 commit d59cacb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion modules/memo/src/main/Picfit.scala
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ final class PicfitUrl(config: PicfitConfig)(using Executor) extends lila.core.mi
height: Int
) =
// parameters must be given in alphabetical order for the signature to work (!)
val queryString = s"h=$height&op=$operation&path=$id&w=$width"
val queryString = s"fmt=webp&h=$height&op=$operation&path=$id&w=$width"
s"${config.endpointGet}/display?${signQueryString(queryString)}"

private object signQueryString:
Expand Down
8 changes: 4 additions & 4 deletions ui/bits/src/bits.cropDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export async function initModule(o?: CropOpts): Promise<void> {
maxWidth: opts.max?.pixels,
maxHeight: opts.max?.pixels,
});
const imgOutputFormat = isPng(opts.source) ? 'png' : 'jpeg';
const imgOutputFormat = isJpeg(opts.source) ? 'jpeg' : 'png';
const tryQuality = (quality = 1) => {
canvas.toBlob(
blob => {
Expand Down Expand Up @@ -156,8 +156,8 @@ export async function initModule(o?: CropOpts): Promise<void> {
}
}

const isPng = (source?: Blob | string) => {
if (source instanceof Blob) return source.type == 'image/png';
if (typeof source == 'string') return source.endsWith('.png');
const isJpeg = (source?: Blob | string) => {
if (source instanceof Blob) return source.type == 'image/jpeg';
if (typeof source == 'string') return /\.jpe?g$/i.test(source);
return false;
};

0 comments on commit d59cacb

Please sign in to comment.