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 9231665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:07:41+00:00 2026-06-18T06:07:41+00:00

I’m using this jQuery plugin to crop images: http://www.tmatthew.net/jwindowcrop As you can see, it’s

  • 0

I’m using this jQuery plugin to crop images:

http://www.tmatthew.net/jwindowcrop

As you can see, it’s really easy to use it on jQuery side, but my problem is with cropping the real image with PHP/GD.

with some goggling, I got:

$targ_w = $targ_h = 150;
$jpeg_quality = 90;

$src = 'demo_files/flowers.jpg';
$img_r = imagecreatefromjpeg($src);
$dst_r = ImageCreateTrueColor( $targ_w, $targ_h );

imagecopyresampled($dst_r,$img_r,0,0,$_POST['x'],$_POST['y'],
    $targ_w,$targ_h,$_POST['w'],$_POST['h']);

header('Content-type: image/jpeg');
imagejpeg($dst_r, null, $jpeg_quality);

But it’s not taking care of zoom ins/zoom outs made by the jQuery plugin, how I should crop the image and save it using this plugin and PHP?

  • 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-06-18T06:07:42+00:00Added an answer on June 18, 2026 at 6:07 am

    I figured this out, here is my code in case of anyone else has the same question, the cropping will be done by Zebra image class:

    http://stefangabos.ro/php-libraries/zebra-image/#documentation

    PHP:

    // The variables we got from the plugin in upload page:
    $x = intval($_POST['x']);
    $y = intval($_POST['y']);
    $w = intval($_POST['w']);
    $h = intval($_POST['h']);
    // The img file which we want to crop
    $tmp_file = 'path/to/img';
    // Now include the Zebra class
    include_once('path/to/Zebra_Image.php');
    $image = new Zebra_Image();
    $image -> preserve_aspect_ratio = true;
    $image -> enlarge_smaller_images = true;
    $image -> preserve_time = true;
    $image -> jpeg_quality = 100;
    // Now imagine that the user has selected the area which he want with the plugin, and we also want to make the image out put in a specific size(200*225):
    $target_path = 'new/img/path'; // the output img path
    $image -> source_path = $tmp_file;
    $image -> target_path = $target_path;
    $image -> crop($x, $y, $x + $w, $y + $h);
    $image -> source_path = $target_path;
    $image -> resize(200, 225,  ZEBRA_IMAGE_CROP_CENTER);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I am using JSon response to parse title,date content and thumbnail images and place
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am using jsonparser to parse data and images obtained from json response. When
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

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.