@@ -19,7 +19,28 @@ from payments.selectors.payment_plan_selector import PaymentPlanSelector class Image_Test_Model(SimpleService): TOKENS_COST = Decimal('3') PLACEHOLDER_URL = 'https://i.pinimg.com/736x/8b/e0/61/8be06158da3986fb4c47497b5660bb29.jpg' - SUPPORTED_RATIOS = frozenset({'1:1', '16:9', '9:16', '4:5', '5:4', '3:4', '4:3'}) + SUPPORTED_RATIOS = frozenset( + { + '1:1', + '16:9', + '9:16', + '4:5', + '5:4', + '3:4', + '4:3', + '2:3', + '3:2', + '9:21', + '20:9', + '21:9', + '1:2', + '2:1', + '19.5:9', + '9:20', + '9:19.5', + '7:4', + } + ) def calculate_price(self, num_images: int = 1) -> Decimal: return self.TOKENS_COST * num_images @@ -90,10 +111,10 @@ class Image_Test_Model(SimpleService): return response.content - def _parse_ratio(self, ratio: str) -> tuple[int, int]: + def _parse_ratio(self, ratio: str) -> tuple[float, float]: if ratio not in self.SUPPORTED_RATIOS: raise InvalidParameterError(f'Unsupported ratio: {ratio}') - rw, rh = map(int, ratio.split(':')) + rw, rh = map(float, ratio.split(':')) return rw, rh def _resize_to_ratio(self, image_bytes: bytes, ratio: str) -> bytes: