Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6945875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:29:33+00:00 2026-05-27T13:29:33+00:00

I have 3 different divs with images in them. Each div with a different

  • 0

I have 3 different divs with images in them. Each div with a different width and height.
I am using jQuery imgAreaSelect on them all. Cropping works fine.
My problem is i would like when the cropping window opens to start with an initial crop.
I would like this initial crop to be the biggest possible porportions for the given aspect ratio.

The code I am working with is:

var aspectratio1 = $('#cutout_'+cutout_id).height() / $('#cutout_'+cutout_id).width();
aspectratio = "1:" + aspectratio1;
var image_width = $('#CutoutImage').width();
var image_height = $('#CutoutImage').height();
var aspect = 1 / aspectratio1 ;
var NewWidth = Math.round(image_height * aspect);
var left = ((image_width - NewWidth) / 2);
var right = Math.round(NewWidth + left);
var x1 = left;
var y1 = 0;
var x2 = right;
var y2 = image_height;

$('#CutoutImage').imgAreaSelect({
    aspectRatio: aspectratio,
    instance: true,
    zIndex: 9999,
    x1: x1,
    y1: y1,
    x2: x2, 
    y2: y2
});

This seems to not be working properly. Any help or insight is much appreciated.

Thank you very much

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:29:34+00:00Added an answer on May 27, 2026 at 1:29 pm

    Well this works good for me

    var aspectratio_cutout = ratio_hw;
    aspectratio = "1:" + mycutout.ratio_hw;
    
    var image_width = $('#imageToCutout').width();
    var image_height = $('#imageToCutout').height();
    var image_ratio_hw = image_height / image_width;
    var image_ratio_wh = image_width / image_height;
    
    if (mycutout.ratio_hw <= ratio_hw) {
        var cropwidth = image_width;
        var cropheight = cropwidth * ratio_hw;
        var x1 = 0;
        var y1 = (image_height - cropheight) / 2;
    } else {
        var cropheight = image_height;
        var cropwidth = cropheight * ratio_wh;
        var x1 = (image_width - cropwidth) / 2;
        var y1 = 0;0;                                                           
    

    }

    var x2 = x1 + cropwidth ;
    var y2 = y1 + cropheight;

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a screen with multiple little widgets (all with different divs around them).
I have a webpage, on which I am using Ajax to replace different divs
I have a few different divs with different projects and names. Each one has
So here is the issue, I have 6 divs that are using jQuery UI
I have 4 divs in the image below. Each div is a link that
I have different php output in jQuery-based tabs. This output is formed from database
I have a question regarding jQuery. I have multiple images that are, in essence,
I want to move some elements (divs with images) vertically at different speed. I
On my website I have several hidden div's with comments. Each comment div is
Currently I have alot of information that are in several different divs. I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.