MEscriva commited on
Commit
33b1984
·
verified ·
1 Parent(s): 45f30b7

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +6 -91
README.md CHANGED
@@ -1,91 +1,6 @@
1
- import React, { useState, useEffect, useRef } from 'react';
2
-
3
- const CroppedImage = () => {
4
- const [image, setImage] = useState(null);
5
- const canvasRef = useRef(null);
6
- const [dimensions, setDimensions] = useState({ width: 0, height: 0 });
7
- const [loading, setLoading] = useState(true);
8
- const [error, setError] = useState(null);
9
-
10
- useEffect(() => {
11
- const img = new Image();
12
- img.crossOrigin = "Anonymous";
13
- img.src = "https://cdn-uploads.huggingface.co/production/uploads/66740b1d0f854ba167e0a01b/vMKLRTVv2r6ibfWd_DcQ1.png";
14
-
15
- img.onload = () => {
16
- setImage(img);
17
- setDimensions({
18
- width: img.width,
19
- height: img.height - 40 // 20px from top and 20px from bottom
20
- });
21
- setLoading(false);
22
- };
23
-
24
- img.onerror = () => {
25
- setError("Impossible de charger l'image. Il s'agit peut-être d'une restriction CORS.");
26
- setLoading(false);
27
- };
28
- }, []);
29
-
30
- useEffect(() => {
31
- if (image && canvasRef.current) {
32
- const canvas = canvasRef.current;
33
- const ctx = canvas.getContext('2d');
34
-
35
- // Set canvas dimensions to match cropped image size
36
- canvas.width = dimensions.width;
37
- canvas.height = dimensions.height;
38
-
39
- // Draw the image with cropping (remove 20px from top)
40
- ctx.drawImage(
41
- image,
42
- 0, 20, // Source x, y (start 20px from the top)
43
- dimensions.width, dimensions.height, // Source width, height
44
- 0, 0, // Destination x, y
45
- dimensions.width, dimensions.height // Destination width, height
46
- );
47
- }
48
- }, [image, dimensions]);
49
-
50
- return (
51
- <div className="flex flex-col items-center justify-center">
52
- {loading ? (
53
- <div className="text-center py-8">Chargement de l'image...</div>
54
- ) : error ? (
55
- <div className="text-red-500 py-8">{error}</div>
56
- ) : (
57
- <>
58
- <div className="mb-4 text-center">
59
- <h2 className="text-lg font-semibold mb-2">Image Rognée</h2>
60
- <p className="text-sm text-gray-600">20 pixels supprimés en haut et en bas</p>
61
- </div>
62
- <div className="border border-gray-300 rounded overflow-hidden">
63
- <canvas
64
- ref={canvasRef}
65
- className="max-w-full h-auto"
66
- style={{ maxWidth: '750px' }}
67
- />
68
- </div>
69
- <div className="mt-4 text-sm text-gray-600">
70
- Dimensions d'origine : {dimensions.width} × {dimensions.height + 40} px<br />
71
- Dimensions après rognage : {dimensions.width} × {dimensions.height} px
72
- </div>
73
- <div className="mt-4 text-sm">
74
- <p className="font-medium">Code HTML pour votre image rognée :</p>
75
- <pre className="bg-gray-100 p-2 rounded mt-1 overflow-x-auto">
76
- {`<p align="center">
77
- <img src="VOTRE_IMAGE_ROGNÉE.png" width="750"/>
78
- </p>`}
79
- </pre>
80
- </div>
81
- </>
82
- )}
83
- </div>
84
- );
85
- };
86
-
87
- export default CroppedImage;
88
-
89
- 👇 **Read our latest article here:**
90
-
91
- ➡️ [Making AI sovereign again – Elixir Blog](https://root-dracorex-f8a.notion.site/Elixir-1d6e3a180b8680cf8fdee53c95a61333)
 
1
+ <p align="center">
2
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/66740b1d0f854ba167e0a01b/vMKLRTVv2r6ibfWd_DcQ1.png" width="750"/>
3
+ </p>
4
+ ---
5
+ 👇 Read our latest article here:
6
+ ➡️ [Making AI sovereign again Elixir Blog](https://root-dracorex-f8a.notion.site/Elixir-1d6e3a180b8680cf8fdee53c95a61333)