--- title: Cache Art Crops status: Completed --- ## Objectives - Ensure "Art Crop" images are cached locally alongside "Normal" images to support offline mode and reduce external API calls. - Update `CardService` (Server) to download and save `.crop.jpg` files. - Update `PackGeneratorService` (Client) to use local `.crop.jpg` URLs when `useLocalImages` is enabled. ## Implementation Details 1. **Server (`CardService.ts`)**: - Modified `cacheImages` loop to detect if `image_uris.art_crop` (or face equivalent) exists. - Implemented concurrent downloading of both the normal image and the art crop. - Saves art crops with the pattern: `public/cards/images/[setCode]/[uuid].crop.jpg`. 2. **Client (`PackGeneratorService.ts`)**: - Updated `processCards` to check the `useLocalImages` flag. - If true, constructs the `imageArtCrop` URL using the local server path: `${origin}/cards/images/${set}/${id}.crop.jpg`. ## Impact - When users import a cube or set collection, both image versions will now be stored. - The Battlefield view (which uses `art_crop`) will now load instantly from the local server cache instead of Scryfall.