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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:24:17+00:00 2026-06-18T09:24:17+00:00

I have a javascript scrict PHP function that allows me to crop images. My

  • 0

I have a javascript scrict PHP function that allows me to crop images.

My problem is that the resulting image is always a black image the same size as the crop field , it does not contain the cropped part of the original image.

A buddy of mine said that the is problem is that is don’t load the stream image, but i’m not sure what he meant nor did he preset any solutions to resolve my problem. Does anyone know how to do it ?

This what i have so far :

if(isset($_POST['decupata'])){
    $new_width=$_POST['w'];//width of the crop field
    $new_height=$_POST['h'];//height of the crop field
    $x=$_POST['x1']; // x of crop field
    $y=$_POST['y1'];// y of crop field
    $num=$_POST['nume'];//name of the original picture


    $old_width=imagesx("../upload/original/".$num);
    $old_height=imagesy("../upload/original/".$num);

    $min_rand=rand(0,1000);
    $max_rand=rand(100000000000,10000000000000000);
    $new_num=rand($min_rand,$max_rand);

    $new_image = imagecreatetruecolor($new_width, $new_height);
    $image = imagecreatefromjpeg("../upload/original/".$num);
    imagecopyresampled($new_image, $image, 0, 0, $x, $y, $new_width, $new_height, $old_width, $old_height);
    imagejpeg($new_image,"../upload/".$new_num.$num,100);
    header('Location:lista_imagini.php');
}
<form action="<?php $_PHP_SELF ?>" method="post" enctype="multipart/form-data" id="coords">
    <input type="text" size="4" id="x1" name="x1"  />
    <input type="text" size="4" id="y1" name="y1"  />   
    <input type="text" size="4" id="x2" name="x2"  />
    <input type="text" size="4" id="y2" name="y2"  />
    <input type="text" size="4" id="w" name="w"  value="<?php echo $width;?>" />
    <input type="text" size="4" id="h" name="h"  value="<?php echo $height;?>" />
    <input type="text" size="4" id="nume" name="nume"  value="<?php echo $num;?>" />
    <input type="text" size="4"  value="<?php echo $old_width;?>" />



    <input type="submit" name="decupata" value="Adauga imaginea" class="buton">
</form>
  • 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-18T09:24:19+00:00Added an answer on June 18, 2026 at 9:24 am

    You take imagesy and imagex from url instead of from created image. Create image first out of this file, like imagecreatefromjpeg

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

Sidebar

Related Questions

I have this Javascript: <script language=javascript type=text/javascript> $().ready(function() { $('#ex2').jqm({ajax: 'view.php?id=<?=$objResult[id];?>', trigger: 'a.ex2trigger'}); });
I have a php script that uses some css/javascript tabs, they work on my
I have a script that allows the user to upload images and preview them.
I have here my Javascript code that adds dynamic textbox (row) my problem is
I have the following simple Javascript code that allows only digits to be entered
The problem: I have a function that partially works and for some reason it
I have a PHP File with something like this: <script type=text/javascript> var page =
in .gsp file i have javaScript function <script type=text/javascript> function getCurrentItemNumber(){ return document.getElementById('item_itemNumber').innerHTML.substr(6); }
I have Javascript as below: <script type="text/javascript" language="javascript"> function redirectToPrevious(abcURL) { window.location.replace(abcURL); } function
I have this javascript code <Script> function getGroupId(){ var group=document.getElementById(selectedOptions).value; var groupFirstLetter=group.substring(2); } </Script>

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.