@zodic/shared 0.0.344 → 0.0.345

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/app/api/index.ts +21 -5
  2. package/package.json +1 -1
package/app/api/index.ts CHANGED
@@ -803,28 +803,44 @@ export const Api = (env: BackendBindings) => ({
803
803
  }
804
804
  };
805
805
 
806
+ // Helper function to generate a resized image URL using Cloudflare Image Transformations
807
+ const getResizedImageUrl = (originalUrl: string, label: string): string => {
808
+ // Use your Cloudflare Worker domain
809
+ const zone = 'https://zodic-backend.lucdelbel.workers.dev';
810
+
811
+ // Construct the Cloudflare Image Transformation URL
812
+ // Resize to fit within 2048x2048 while maintaining proportions
813
+ const resizedUrl = `${zone}/cdn-cgi/image/width=2048,height=2048,fit=scale-down/${encodeURIComponent(originalUrl)}`;
814
+
815
+ console.log(`${label} resized URL:`, resizedUrl);
816
+ return resizedUrl;
817
+ };
818
+
806
819
  try {
807
820
  // Validate image URLs
808
821
  await validateImageUrl(sourceImageUrl, 'Source image URL');
809
822
  await validateImageUrl(targetImageUrl, 'Target image URL');
810
823
 
824
+ // Generate resized URLs using Cloudflare Image Transformations
825
+ const resizedSourceUrl = getResizedImageUrl(sourceImageUrl, 'Source image');
826
+ const resizedTargetUrl = getResizedImageUrl(targetImageUrl, 'Target image');
827
+
811
828
  const body = JSON.stringify({
812
829
  model: 'Qubico/image-toolkit',
813
830
  type: 'face-swap',
814
831
  input: {
815
- swap_image: sourceImageUrl,
816
- target_image: targetImageUrl,
832
+ swap_image: resizedSourceUrl,
833
+ target_image: resizedTargetUrl,
817
834
  },
818
835
  config: {
819
836
  webhook_config: {
820
- endpoint:
821
- 'https://zodic-backend.lucdelbel.workers.dev/api/webhook/faceswap',
837
+ endpoint: 'https://zodic-backend.lucdelbel.workers.dev/api/webhook/faceswap',
822
838
  // secret: '',
823
839
  },
824
840
  },
825
841
  });
826
842
 
827
- console.log('Sending FaceSwap request:', { sourceImageUrl, targetImageUrl });
843
+ console.log('Sending FaceSwap request:', { resizedSourceUrl, resizedTargetUrl });
828
844
 
829
845
  const response = await fetch(endpoint, {
830
846
  method: 'POST',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zodic/shared",
3
- "version": "0.0.344",
3
+ "version": "0.0.345",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "publishConfig": {