4images Forum & Community
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 24, 2018, 09:25:59 PM

Login with username, password and session length
Search:     Advanced search
4images is now on facebook. Click here and become a fan!
Togle to toolbar
Translate this page with =>
Translate this page >
* Home Help Search Login Register
 
+  4images Forum & Community
|-+  4images Modifications / Modifikationen
| |-+  Mods & Plugins (Requests & Discussions) (Moderators: mawenzi, Rembrandt)
| | |-+  Rotating picture by user online
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: «« « 1 2 [3] Print
Author Topic: Rotating picture by user online  (Read 35599 times)
lemccoy
Jr. Member
**
Offline Offline

Posts: 90

Thank You
-Given: 0
-Receive: 0


View Profile WWW
« Reply #30 on: February 18, 2006, 01:50:06 PM »

Works like a champ...thanks V@no!
Logged
sparky
Newbie
*
Offline Offline

Posts: 19

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #31 on: October 16, 2006, 11:31:16 PM »

We have one post after another flipping stuff around and it's getting a little confusing.  I understand this is how things improve through community participation but I'm not sure which posters found a working solution as some people are updating pieces of other's work.

I was wondering if someone can post a verified final working version of this all in one place.

I've tried every rotate.php script version in this thread and none of them are working for me.

Depending on the version of rotate.php I get one of two things...

1.  White screen and nothing else happens.

or

2.  Internal Server Error.


I'm using 4images 1.7.2

I'm only interested in the admin having this new function.  So I added the rotate.php to the includes directory.  I added the rotate text to my language file.  Then I changed the details.php so that there are links for the admin to rotate on the details page. (the links are displaying fine.)

That's all I did.  Did I miss something or do I need to find the correct "rotate.php" version or combination of pieces of these rotate.php versions?
Logged
sparky
Newbie
*
Offline Offline

Posts: 19

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #32 on: October 17, 2006, 12:00:59 AM »

To add the rotate button for the admin:

Replace includes/rotate.php with this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?
// change to suit your needs eg: define (JPG_QUALITY, '75'); gives a more compressed
// image file, but a poorer quality, when re-writing the jpeg after rotation.

define('JPG_QUALITY', '100');


//define variables and includes (should be no need to change these)
define('ROOT_PATH', './../');
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
$user_access = get_permission();


//is there an image_id and does the user have permission to delete the image? If not, send them back to the index page!
if (!$image_id || ($config['user_delete_image'] != 1)) {
    header("Location: ".$site_sess->url(ROOT_PATH."index.php", "&"));
    exit;
  }
 
//if ok so far, read the image info from the database 
  $sql = "SELECT image_id, cat_id, user_id, image_name, image_media_file, image_thumb_file
          FROM ".IMAGES_TABLE."
          WHERE image_id = $image_id";
         
  $image_row = $site_db->query_firstrow($sql);

//is the user a registered user and the 'owner' of the image? If not, send them back to the index page!
  if ($user_info['user_level'] == ADMIN OR !$image_row || $image_row['user_id'] <= USER_AWAITING || ($user_info['user_id'] = $image_row['user_id'])) {

 
//so far so good, more variables need defining...
$ok=false;
$file=$image_row[image_media_file];
$cat_id=$image_row[cat_id];
$path_to_media = ROOT_PATH.MEDIA_DIR."/".$cat_id."/";
$path_to_thumbs = ROOT_PATH.THUMB_DIR."/".$cat_id."/";
$ext = get_file_extension($file); 

//clockwise or anticlockwise?
$degrees=0;
if ($wize=="neg"){$degrees = 90;}
if ($wize=="180"){$degrees = 180;}
if ($wize=="pos"){$degrees = 270;}

// Load existing images (if a 'jpg')
if (($ext == "jpg") || ($ext == "jpeg"))
{
$source_image = imagecreatefromjpeg($path_to_media.$file);
$source_thumb = imagecreatefromjpeg($path_to_thumbs.$file);
$ok=true;
}

// Load existing images (if a 'gif')
if ($ext == "gif")
{
$source_image = imagecreatefromgif($path_to_media.$file);
$source_thumb = imagecreatefromgif($path_to_thumbs.$file);
$ok=true;
}

if ($ok) //is it ok to process?
{
// Rotate
$rotate_image = imagerotate($source_image, $degrees, 0);
$rotate_thumb = imagerotate($source_thumb, $degrees, 0);

//Create new file names using timestamp as 'random' prefix to force browser to reload
$new_file_name=time().".".$ext;
$new_image = $path_to_media.$new_file_name;
$new_thumb = $path_to_thumbs.$new_file_name;

//Output 'new' images
if (($ext == "jpg") || ($ext == "jpeg"))
{
imagejpeg($rotate_image,$new_image,JPG_QUALITY);
imagejpeg($rotate_thumb,$new_thumb,JPG_QUALITY);
}

if ($ext == "gif")
{
imagegif($rotate_image,$new_image);
imagegif($rotate_thumb,$new_thumb);
}

//Delete 'old' files
unlink($path_to_media.$file);
unlink($path_to_thumbs.$file);
imagedestroy($rotate_image);
imagedestroy($rotate_thumb);
imagedestroy($source_image);
imagedestroy($source_thumb);


//write 'new' filenames to database
$sql=" UPDATE `4images_images`
SET `image_media_file` = '$new_file_name',`image_thumb_file` = '$new_file_name'
WHERE `image_id` = '$image_id'
LIMIT 1";

$result = $site_db->query($sql);

} //end of processing

//display new rotated image
header("Location: ".$site_sess->url(ROOT_PATH."details.php?&".URL_IMAGE_ID."=".$image_id, "&"));
}
  elseif (!$image_row || $image_row['user_id'] <= USER_AWAITING || ($user_info['user_id'] != $image_row['user_id'])) {
    header("Location: ".$site_sess->url(ROOT_PATH."index.php", "&"));
      exit;
  }

?>

Open details.php

FIND:
1
2
3
4
if ($user_info['user_level'] == ADMIN) {
  $admin_links .= "<a href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("images.php?action=editimage&amp;image_id=".$image_id))."\" target=\"_blank\">".$lang['edit']."</a>&nbsp;";
  $admin_links .= "<a href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("images.php?action=removeimage&amp;image_id=".$image_id))."\" target=\"_blank\">".$lang['delete']."</a>&nbsp;";
}

REPLACE WITH:
1
2
3
4
5
6
if ($user_info['user_level'] == ADMIN) {
  $admin_links .= "<a href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("images.php?action=editimage&amp;image_id=".$image_id))."\" target=\"_blank\">".$lang['edit']."</a>&nbsp;";
  $admin_links .= "<a href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("images.php?action=removeimage&amp;image_id=".$image_id))."\" target=\"_blank\">".$lang['delete']."</a>&nbsp;";
  $admin_links .= "<a href=\"".$site_sess->url(ROOT_PATH."includes/rotate.php?".URL_IMAGE_ID."=".$image_id."&amp;wize=90")."\">".$lang['rotate_neg']."</a>&nbsp;";
  $admin_links .= "<a href=\"".$site_sess->url(ROOT_PATH."includes/rotate.php?".URL_IMAGE_ID."=".$image_id."&amp;wize=270")."\">".$lang['rotate_pos']."</a>";
}

When an Image is uploaded, you get a page with te result, is it possible to add the rotate option to that page?
 Exclamation


Even though I found a major problem with your code, I still can't get it to work. Exclamation

Arrow In your rotate.php you are looking for variable wize to be "pos"...

[qcode]//clockwise or anticlockwise?
$degrees=0;
if ($wize=="neg"){$degrees = 90;}
if ($wize=="180"){$degrees = 180;}
if ($wize=="pos"){$degrees = 270;}
[/qcode]

Arrow But your new admin links are passing variable wize as "270"...

[qcode]$admin_links .= "<a href=\"".$site_sess->url(ROOT_PATH."includes/rotate.php?".URL_IMAGE_ID."=".$image_id."&amp;wize=270")."\">".$lang['rotate_pos']."</a>";[/qcode]
Logged
matosale
Full Member
***
Offline Offline

Posts: 160

Thank You
-Given: 0
-Receive: 0


View Profile WWW
« Reply #33 on: October 11, 2007, 06:05:08 PM »

Iv'e tried this with 1.7.4 without luck. The links are shown, but nothing happens when clicked. Am I missing something?
Thanks!
Logged

Alejandro Matos
   Lima - Perú

   Linz - Austria
   Helsinki - Finland
   Seville - Spain


Eremit
Pre-Newbie

Offline Offline

Posts: 6

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #34 on: June 28, 2008, 05:24:24 PM »

Hi,

i have the same problem.
The button for "rotate" is still there but the code does not rotate the image. After the operation as "root" i am in the index.php.

Can someone help me?

Deutsch:
Ich habe das gleiche Problem.
Der Button ist da aber wenn ich darauf klicke lande ich in der index.php im Hauptverzeichnis.

Kann jemand helfen?

Eremit




-> rotate.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?
// change to suit your needs eg: define (JPG_QUALITY, '75'); gives a more compressed
// image file, but a poorer quality, when re-writing the jpeg after rotation.

define('JPG_QUALITY''100'); 


//define variables and includes (should be no need to change these)
define('ROOT_PATH''./../');
include(
ROOT_PATH.'global.php');
require(
ROOT_PATH.'includes/sessions.php');
$user_access get_permission();


//is there an image_id and does the user have permission to delete the image? If not, send them back to the index page!
if (!$image_id || ($config['user_delete_image'] != 1)) {
    
header("Location: ".$site_sess->url(ROOT_PATH."index.php""&"));
    exit;
  }
  
//if ok so far, read the image info from the database  
  
$sql "SELECT image_id, cat_id, user_id, image_name, image_media_file, image_thumb_file
          FROM "
.IMAGES_TABLE."
          WHERE image_id = 
$image_id";
          
  
$image_row $site_db->query_firstrow($sql);

//is the user a registered user and the 'owner' of the image? If not, send them back to the index page!
  
if (!$image_row || $image_row['user_id'] <= USER_AWAITING || ($user_info['user_id'] != $image_row['user_id'])) {
  
	
  
header("Location: ".$site_sess->url(ROOT_PATH."index.php""&"));
      exit;
  }
  
//so far so good, more variables need defining...
$ok=false;
$file=$image_row[image_media_file];
$cat_id=$image_row[cat_id];
$path_to_media ROOT_PATH.MEDIA_DIR."/".$cat_id."/";
$path_to_thumbs ROOT_PATH.THUMB_DIR."/".$cat_id."/";
$ext get_file_extension($file);  
 
//clockwise or anticlockwise?
$degrees=0;
if (
$wize=="pos"){$degrees 270;}
if (
$wize=="neg"){$degrees 90;}

// Load existing images (if a 'jpg')
if (($ext == "jpg") || ($ext == "jpeg"))

$source_image imagecreatefromjpeg($path_to_media.$file);
$source_thumb imagecreatefromjpeg($path_to_thumbs.$file);
$ok=true;
}

// Load existing images (if a 'gif')
if ($ext == "gif")

$source_image imagecreatefromgif($path_to_media.$file);
$source_thumb imagecreatefromgif($path_to_thumbs.$file);
$ok=true;
}

if (
$ok//is it ok to process?
{
	
// Rotate
	
	
$rotate_image imagerotate($source_image$degrees0);
	
	
$rotate_thumb imagerotate($source_thumb$degrees0);

	
//Create new file names using timestamp as 'random' prefix to force browser to reload
	
	
$new_file_name=time().".".$ext;
	
	
$new_image $path_to_media.$new_file_name;
	
	
$new_thumb $path_to_thumbs.$new_file_name;
	
	

	
//Output 'new' images
	
	
if ((
$ext == "jpg") || ($ext == "jpeg"))
	
	

	
	
imagejpeg($rotate_image,$new_image,JPG_QUALITY);
	
	
imagejpeg($rotate_thumb,$new_thumb,JPG_QUALITY);
	
	
}
	
	

	
	
if (
$ext == "gif")
	
	
{
	
	
imagegif($rotate_image,$new_image);
	
	
imagegif($rotate_thumb,$new_thumb);
	
	
}

	
//Delete 'old' files
	
	
unlink($path_to_media.$file);
	
	
unlink($path_to_thumbs.$file);
	
	
imagedestroy($rotate_image);
	
	
imagedestroy($rotate_thumb);
	
	
imagedestroy($source_image);
	
	
imagedestroy($source_thumb);


	
//write 'new' filenames to database
	
	
$sql="
	
UPDATE `4images_images` 
	
	
	
	
SET `image_media_file` = '
$new_file_name',`image_thumb_file` = '$new_file_name'
	
	
	
	
WHERE `image_id` = '
$image_id
	
	
	
	
LIMIT 1"
;

	
	
$result $site_db->query($sql);

//end of processing

//display new rotated image
header("Location: ".$site_sess->url(ROOT_PATH."details.php?&".URL_IMAGE_ID."=".$image_id"&"));


?>
« Last Edit: November 04, 2011, 04:47:52 AM by Rembrandt » Logged
maylord
Jr. Member
**
Offline Offline

Posts: 50

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #35 on: November 03, 2011, 09:53:53 PM »

I'm looking for a script that rotates an image like the one in the first post!

My version is the latest 1.7.10... Is there a chance to get it work?

Martin
Logged
Redstick
Pre-Newbie

Offline Offline

Posts: 1

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #36 on: June 27, 2017, 11:07:36 PM »

How can i do this with V1.8?
Is there a ready made mod/plug in?
Will the solution given in this thread work with 1.8?
Logged
Pages: «« « 1 2 [3] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.073 seconds with 19 queries.