Rename image size config constants

IMAGE_SIZE_CONFIG_POSTS (4000px/2MB) and IMAGE_SIZE_CONFIG_2K_1MB
(2000px/1MB), replacing POST_IMG_MAX_SIZE and PROFILE_IMAGES_MAX_SIZE.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Eric Bailey
2026-06-02 12:25:02 -05:00
parent 736acb8a61
commit 2c3cba67c2
10 changed files with 29 additions and 29 deletions
+5 -5
View File
@@ -1,7 +1,7 @@
import {createDownloadResumable, deleteAsync} from 'expo-file-system/legacy'
import {manipulateAsync, SaveFormat} from 'expo-image-manipulator'
import {PROFILE_IMAGES_MAX_SIZE} from '../../src/lib/constants'
import {IMAGE_SIZE_CONFIG_2K_1MB} from '../../src/lib/constants'
import {
downloadAndResize,
type DownloadAndResizeOpts,
@@ -91,7 +91,7 @@ describe('downloadAndResize', () => {
}
const resizedDimensionsOne = getResizedDimensions(
initialDimensionsOne,
PROFILE_IMAGES_MAX_SIZE,
IMAGE_SIZE_CONFIG_2K_1MB,
)
const initialDimensionsTwo = {
@@ -100,7 +100,7 @@ describe('downloadAndResize', () => {
}
const resizedDimensionsTwo = getResizedDimensions(
initialDimensionsTwo,
PROFILE_IMAGES_MAX_SIZE,
IMAGE_SIZE_CONFIG_2K_1MB,
)
expect(resizedDimensionsOne).toEqual(initialDimensionsOne)
@@ -114,7 +114,7 @@ describe('downloadAndResize', () => {
}
const resizedDimensionsOne = getResizedDimensions(
initialDimensionsOne,
PROFILE_IMAGES_MAX_SIZE,
IMAGE_SIZE_CONFIG_2K_1MB,
)
const initialDimensionsTwo = {
@@ -123,7 +123,7 @@ describe('downloadAndResize', () => {
}
const resizedDimensionsTwo = getResizedDimensions(
initialDimensionsTwo,
PROFILE_IMAGES_MAX_SIZE,
IMAGE_SIZE_CONFIG_2K_1MB,
)
expect(resizedDimensionsOne).toEqual({
+2 -2
View File
@@ -21,7 +21,7 @@ import {sha256} from 'js-sha256'
import {CID} from 'multiformats/cid'
import * as Hasher from 'multiformats/hashes/hasher'
import {POST_IMG_MAX_SIZE} from '#/lib/constants'
import {IMAGE_SIZE_CONFIG_POSTS} from '#/lib/constants'
import {isNetworkError} from '#/lib/strings/errors'
import {shortenLinks, stripInvalidMentions} from '#/lib/strings/rich-text-manip'
import {logger} from '#/logger'
@@ -326,7 +326,7 @@ async function resolveMedia(
logger.debug(`Compressing image #${i}`)
const {path, width, height, mime} = await compressImage(
image,
POST_IMG_MAX_SIZE,
IMAGE_SIZE_CONFIG_POSTS,
)
logger.debug(`Uploading image #${i}`)
const res = await uploadBlob(agent, path, mime)
+3 -3
View File
@@ -6,7 +6,7 @@ import {
} from '@atproto/api'
import {AtUri} from '@atproto/api'
import {PROFILE_IMAGES_MAX_SIZE} from '#/lib/constants'
import {IMAGE_SIZE_CONFIG_2K_1MB} from '#/lib/constants'
import {getLinkMeta, type LinkMeta} from '#/lib/link-meta/link-meta'
import {resolveShortLink} from '#/lib/link-meta/resolve-short-link'
import {downloadAndResize} from '#/lib/media/manip'
@@ -257,8 +257,8 @@ export async function imageToThumb(
try {
const img = await downloadAndResize({
uri: imageUri,
maxDimension: PROFILE_IMAGES_MAX_SIZE.width,
maxSize: PROFILE_IMAGES_MAX_SIZE.size,
maxDimension: IMAGE_SIZE_CONFIG_2K_1MB.width,
maxSize: IMAGE_SIZE_CONFIG_2K_1MB.size,
timeout: 15e3,
})
if (img) {
+2 -2
View File
@@ -96,13 +96,13 @@ export const STAGING_FEEDS = [
`feedgen|${STAGING_DEFAULT_FEED('thevids')}`,
]
export const POST_IMG_MAX_SIZE = {
export const IMAGE_SIZE_CONFIG_POSTS = {
width: 4000,
height: 4000,
size: 2000000,
}
export const PROFILE_IMAGES_MAX_SIZE = {
export const IMAGE_SIZE_CONFIG_2K_1MB = {
width: 2000,
height: 2000,
size: 1000000,
+2 -2
View File
@@ -8,7 +8,7 @@ import ExpoImageCropTool, {
type OpenCropperOptions,
} from '@bsky.app/expo-image-crop-tool'
import {PROFILE_IMAGES_MAX_SIZE} from '#/lib/constants'
import {IMAGE_SIZE_CONFIG_2K_1MB} from '#/lib/constants'
import {compressIfNeeded} from './manip'
import {type PickerImage} from './picker.shared'
@@ -37,7 +37,7 @@ async function getFile() {
width: 4288,
height: 2848,
},
PROFILE_IMAGES_MAX_SIZE,
IMAGE_SIZE_CONFIG_2K_1MB,
)
}
+2 -2
View File
@@ -19,7 +19,7 @@ import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react'
import {Trans} from '@lingui/react/macro'
import {PROFILE_IMAGES_MAX_SIZE} from '#/lib/constants'
import {IMAGE_SIZE_CONFIG_2K_1MB} from '#/lib/constants'
import {usePhotoLibraryPermission} from '#/lib/hooks/usePermissions'
import {compressIfNeeded} from '#/lib/media/manip'
import {openCropper} from '#/lib/media/picker'
@@ -213,7 +213,7 @@ export function StepProfile() {
}
}
}
image = await compressIfNeeded(image, PROFILE_IMAGES_MAX_SIZE)
image = await compressIfNeeded(image, IMAGE_SIZE_CONFIG_2K_1MB)
// If we are on mobile, prefetching the image will load the image into memory before we try and display it,
// stopping any brief flickers.
@@ -3,7 +3,7 @@ import * as MediaLibrary from 'expo-media-library'
import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react'
import {POST_IMG_MAX_SIZE} from '#/lib/constants'
import {IMAGE_SIZE_CONFIG_POSTS} from '#/lib/constants'
import {useCameraPermission} from '#/lib/hooks/usePermissions'
import {openCamera} from '#/lib/media/picker'
import {logger} from '#/logger'
@@ -35,7 +35,7 @@ export function OpenCameraBtn({disabled, onAdd}: Props) {
}
const img = await openCamera({
aspect: [POST_IMG_MAX_SIZE.width, POST_IMG_MAX_SIZE.height],
aspect: [IMAGE_SIZE_CONFIG_POSTS.width, IMAGE_SIZE_CONFIG_POSTS.height],
})
// If we don't have permissions it's fine, we just wont save it. The post itself will still have access to
@@ -16,7 +16,7 @@ import {type PasteEventPayload, TextInputWrapper} from 'expo-paste-input'
import {AppBskyRichtextFacet, RichText} from '@atproto/api'
import {useLingui} from '@lingui/react/macro'
import {POST_IMG_MAX_SIZE} from '#/lib/constants'
import {IMAGE_SIZE_CONFIG_POSTS} from '#/lib/constants'
import {downloadAndResize} from '#/lib/media/manip'
import {isUriImage} from '#/lib/media/util'
import {getMentionAt, insertMentionAt} from '#/lib/strings/mention-manip'
@@ -93,8 +93,8 @@ export function TextInput({
if (isUriImage(feature.uri)) {
const res = await downloadAndResize({
uri: feature.uri,
maxDimension: POST_IMG_MAX_SIZE.width,
maxSize: POST_IMG_MAX_SIZE.size,
maxDimension: IMAGE_SIZE_CONFIG_POSTS.width,
maxSize: IMAGE_SIZE_CONFIG_POSTS.size,
timeout: 15e3,
})
+4 -4
View File
@@ -17,7 +17,7 @@ import {useLingui} from '@lingui/react'
import {Trans} from '@lingui/react/macro'
import {useQueryClient} from '@tanstack/react-query'
import {PROFILE_IMAGES_MAX_SIZE} from '#/lib/constants'
import {IMAGE_SIZE_CONFIG_2K_1MB} from '#/lib/constants'
import {useHaptics} from '#/lib/haptics'
import {
useCameraPermission,
@@ -395,7 +395,7 @@ let EditableUserAvatar = ({
await openCamera({
aspect: [1, 1],
}),
PROFILE_IMAGES_MAX_SIZE,
IMAGE_SIZE_CONFIG_2K_1MB,
),
)
}, [onSelectNewAvatar, requestCameraAccessIfNeeded])
@@ -424,7 +424,7 @@ let EditableUserAvatar = ({
shape: circular ? 'circle' : 'rectangle',
aspectRatio: 1,
}),
PROFILE_IMAGES_MAX_SIZE,
IMAGE_SIZE_CONFIG_2K_1MB,
),
)
} else {
@@ -451,7 +451,7 @@ let EditableUserAvatar = ({
const onChangeEditImage = useCallback(
async (image: ComposerImage) => {
const compressed = await compressImage(image, PROFILE_IMAGES_MAX_SIZE)
const compressed = await compressImage(image, IMAGE_SIZE_CONFIG_2K_1MB)
onSelectNewAvatar(compressed)
},
[onSelectNewAvatar],
+4 -4
View File
@@ -6,7 +6,7 @@ import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react'
import {Trans} from '@lingui/react/macro'
import {PROFILE_IMAGES_MAX_SIZE} from '#/lib/constants'
import {IMAGE_SIZE_CONFIG_2K_1MB} from '#/lib/constants'
import {
useCameraPermission,
usePhotoLibraryPermission,
@@ -63,7 +63,7 @@ export function UserBanner({
await openCamera({
aspect: [3, 1],
}),
PROFILE_IMAGES_MAX_SIZE,
IMAGE_SIZE_CONFIG_2K_1MB,
),
)
}, [onSelectNewBanner, requestCameraAccessIfNeeded])
@@ -85,7 +85,7 @@ export function UserBanner({
imageUri: items[0].path,
aspectRatio: 3 / 1,
}),
PROFILE_IMAGES_MAX_SIZE,
IMAGE_SIZE_CONFIG_2K_1MB,
),
)
} else {
@@ -111,7 +111,7 @@ export function UserBanner({
const onChangeEditImage = useCallback(
async (image: ComposerImage) => {
const compressed = await compressImage(image, PROFILE_IMAGES_MAX_SIZE)
const compressed = await compressImage(image, IMAGE_SIZE_CONFIG_2K_1MB)
onSelectNewBanner?.(compressed)
},
[onSelectNewBanner],