0

I need to validate the measurement of the photo attached. Profile photos should be 45 mm * 35 mm

$('#image-file').on('change', function(event) {
  var photoSize = parseInt($("#sizeOne").val());
  if (photoSize > 350000 && photoSize < 450000) {
    $("#errorMsg").text("<spring:message code='sth.browseimage'/>");
    $('#modal').modal('show');
    event.preventDefault();
  }
});

Thank you very much

vadivel a
  • 1,754
  • 1
  • 8
  • 18
  • 2
    You cannot validate the physical dimensions of a photo as that depends on the DPI used when printing. All you can do is validate the size in pixels. That said, most photos are printed at 300dpi which would give you an approximate image size of 411*531 – Rory McCrossan Feb 13 '20 at 16:10
  • I see how I can do that ? – james daniel Feb 13 '20 at 16:12
  • https://stackoverflow.com/questions/12570834/get-file-size-image-width-and-height-before-upload, https://stackoverflow.com/questions/13572129/is-it-possible-to-check-dimensions-of-image-before-uploading – Rory McCrossan Feb 13 '20 at 16:12
  • I removed the java-related tags, since the fact that you use spring is quite irrelevant to the question at hand. – Federico klez Culloca Feb 13 '20 at 16:12
  • @RoryMcCrossan My idea: Scan a real photo which has the size 45x35 mm and save it in local computer. Then we can get the width and height of that photo in pixel via uploading. Is that good? – Tân Feb 13 '20 at 16:17
  • I have a picture 1024*1024. When I try to upload a pop up should be come out. All that I want – james daniel Feb 13 '20 at 16:22
  • 1
    @Tân not really, as the DPI resolution of the scanner probably won't match the printer. There's no reliable way to approximate the size of a printed photo as you can manipulate it however is required. – Rory McCrossan Feb 13 '20 at 16:23

0 Answers0