title: Read data from image and crop certain part of image in node js
body: <p>My Client has requirement that user will upload image using that image i have to read data and crop some part of image. I am able to get read data from image using <a href="https://tesseract.projectnaptha.com/" rel="nofollow noreferrer">tesseract.js</a> node module. Cropping part is also done it only work form some image not working for all images. below code to get data form images.</p>
  
  <pre><code>const Tesseract = require("tesseract.js");
  
  Tesseract.recognize("./pancard.jpg", "eng", {
    logger: m =&gt; console.log(m)
  }).then(({ data: { text } }) =&gt; {
    console.log(text);
  });
  </code></pre>
  
  <p>For cropping image i am using sharp node module. below code basically resize image after resizing image its crop particular data. </p>
  
  <pre><code>const sharp = require("sharp");
  sharp("./pancard.jpg")
    .resize(500, 300, {
      fit: sharp.fit.fill
    })
    .toFile("./pancard_new.jpg", (err, info) =&gt; {
      sharp("./pancard_new.jpg")
        .extract({ left: 35, top: 220, width: 180, height: 28 })
        .toFile("./pancard_new2.jpg", function(err) {});
    });
  </code></pre>
  
  <p>Above code working fine for below image i am able to get signature of that particular images. 
  <a href="https://i.stack.imgur.com/ZZsiO.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZZsiO.jpg" alt="Image"></a></p>
  
  <p>but same code not working for below image.
  <a href="https://i.stack.imgur.com/gRJL5.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gRJL5.jpg" alt="Other image"></a></p>
  
  <p>Basically i want to crop signature from that images. If someone have idea how to start from where to start to do above task please help me out.</p>
  
  <p>Note*: Images are from google.</p>