1
0
mirror of https://github.com/mosbth/cimage.git synced 2025-08-26 17:14:27 +02:00

Compare commits

..

9 Commits

Author SHA1 Message Date
Mikael Roos
b44be78f06 Fix deprecation notice on "Creation of dynamic property" for PHP 8.2. 2023-10-27 10:20:16 +02:00
Mikael Roos
1056f0a5ee Spelling in README 2022-11-17 16:13:56 +01:00
Mikael Roos
1666ea1412 Build to prepare to tag 2022-11-17 16:08:48 +01:00
Mikael Roos
bb57af697b Remove build status from README (since it is not up to date) 2022-11-17 16:06:25 +01:00
Mikael Roos
55ce23ae5e Add fix for WINDOWS2WSL 2022-11-17 16:05:25 +01:00
Mikael Roos
4589b3b3cd Enable configuration fix for solving Windows 2 WSL2 issue with is_readable/is_writable #189 2022-11-17 15:40:43 +01:00
Mikael Roos
d5ca10cebc Add a webpage with links useful to test various aspects of img.php 2022-11-17 15:31:40 +01:00
Mikael Roos
9d7343a2df Merge pull request #188 from niciz/patch-1
Update CHttpGet.php for php 8.1 deprecated notice
2022-11-08 13:50:12 +01:00
niciz
3d7adcdbde Update CHttpGet.php for php 8.1 deprecated notice 2022-11-08 12:23:07 +01:00
12 changed files with 123 additions and 19 deletions

View File

@@ -51,6 +51,15 @@ class CCache
return $path;
}
if ($create && defined('WINDOWS2WSL')) {
// Special case to solve Windows 2 WSL integration
$path = $this->path . "/" . $subdir;
if (mkdir($path)) {
return realpath($path);
}
}
if ($create && is_writable($this->path)) {
$path = $this->path . "/" . $subdir;

View File

@@ -215,7 +215,7 @@ class CHttpGet
{
$type = isset($this->response['header']['Content-Type'])
? $this->response['header']['Content-Type']
: null;
: '';
return preg_match('#[a-z]+/[a-z]+#', $type)
? $type

View File

@@ -6,6 +6,7 @@
* @example http://dbwebb.se/opensource/cimage
* @link https://github.com/mosbth/cimage
*/
#[AllowDynamicProperties]
class CImage
{
@@ -964,8 +965,11 @@ class CImage
{
$file = $file ? $file : $this->pathToImage;
is_readable($file)
or $this->raiseError('Image file does not exist.');
// Special case to solve Windows 2 WSL integration
if (!defined('WINDOWS2WSL')) {
is_readable($file)
or $this->raiseError('Image file does not exist.');
}
$info = list($this->width, $this->height, $this->fileType) = getimagesize($file);
if (empty($info)) {
@@ -2440,8 +2444,10 @@ class CImage
return;
}
is_writable($this->saveFolder)
if (!defined("WINDOWS2WSL")) {
is_writable($this->saveFolder)
or $this->raiseError('Target directory is not writable.');
}
$type = $this->getTargetImageExtension();
$this->Log("Saving image as " . $type);

View File

@@ -2,8 +2,10 @@ Image conversion on the fly using PHP
=====================================
[![Join the chat at https://gitter.im/mosbth/cimage](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/mosbth/cimage?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
<!--
[![Build Status](https://travis-ci.org/mosbth/cimage.svg?branch=master)](https://travis-ci.org/mosbth/cimage)
[![Build Status](https://scrutinizer-ci.com/g/mosbth/cimage/badges/build.png?b=master)](https://scrutinizer-ci.com/g/mosbth/cimage/build-status/master)
-->
About
-------------------------------------

View File

@@ -1,8 +1,25 @@
Revision history
=====================================
<!--
[![Build Status](https://travis-ci.org/mosbth/cimage.svg?branch=master)](https://travis-ci.org/mosbth/cimage)
[![Build Status](https://scrutinizer-ci.com/g/mosbth/cimage/badges/build.png?b=master)](https://scrutinizer-ci.com/g/mosbth/cimage/build-status/master)
--->
v0.8.6 (2023-10-27)
-------------------------------------
* Fix deprecation notice on "Creation of dynamic property" for PHP 8.2.
v0.8.5 (2022-11-17)
-------------------------------------
* Enable configuration fix for solving Windows 2 WSL2 issue with is_readable/is_writable #189.
* Update CHttpGet.php for php 8.1 deprecated notice #188.
* Remove build status from README (since it is not up to date).
v0.8.4 (2022-05-30)

View File

@@ -1,6 +1,6 @@
<?php
// Version of cimage and img.php
define("CIMAGE_VERSION", "v0.8.4 (2022-05-30)");
define("CIMAGE_VERSION", "v0.8.6 (2023-10-27)");
// For CRemoteImage
define("CIMAGE_USER_AGENT", "CImage/" . CIMAGE_VERSION);

View File

@@ -15,6 +15,15 @@ services:
- "8090:80"
volumes: [ ".:/home/anax/repo" ]
php82:
image: anax/dev:php82
volumes: [ ".:/home/anax/repo" ]
php82-apache:
image: anax/dev:php82-apache
ports: [ "11082:80" ]
volumes: [ ".:/home/anax/repo" ]
php81:
image: anax/dev:php81
volumes: [ ".:/home/anax/repo" ]

View File

@@ -21,6 +21,15 @@ if (!defined("CIMAGE_DEBUG")) {
define("CIMAGE_DEBUG_FILE", "/tmp/cimage");
}
/**
* Set this if you work with a webserver in Windows and try to access files
* within WSL2.
* The issue seems to be with functions like `is_writable()` and
* `is_readable()`.
* When WINDOWS2WSL is defined (to any value) it ignores these functions.
*/
#define('WINDOWS2WSL', 1);
return array(

View File

@@ -38,7 +38,7 @@ $config = array(
// Version of cimage and img.php
define("CIMAGE_VERSION", "v0.8.4 (2022-05-30)");
define("CIMAGE_VERSION", "v0.8.6 (2023-10-27)");
// For CRemoteImage
define("CIMAGE_USER_AGENT", "CImage/" . CIMAGE_VERSION);
@@ -465,7 +465,7 @@ class CHttpGet
{
$type = isset($this->response['header']['Content-Type'])
? $this->response['header']['Content-Type']
: null;
: '';
return preg_match('#[a-z]+/[a-z]+#', $type)
? $type
@@ -1143,6 +1143,7 @@ class CAsciiArt
* @example http://dbwebb.se/opensource/cimage
* @link https://github.com/mosbth/cimage
*/
#[AllowDynamicProperties]
class CImage
{
@@ -2101,8 +2102,11 @@ class CImage
{
$file = $file ? $file : $this->pathToImage;
is_readable($file)
or $this->raiseError('Image file does not exist.');
// Special case to solve Windows 2 WSL integration
if (!defined('WINDOWS2WSL')) {
is_readable($file)
or $this->raiseError('Image file does not exist.');
}
$info = list($this->width, $this->height, $this->fileType) = getimagesize($file);
if (empty($info)) {
@@ -3577,8 +3581,10 @@ class CImage
return;
}
is_writable($this->saveFolder)
if (!defined("WINDOWS2WSL")) {
is_writable($this->saveFolder)
or $this->raiseError('Target directory is not writable.');
}
$type = $this->getTargetImageExtension();
$this->Log("Saving image as " . $type);
@@ -4140,6 +4146,15 @@ class CCache
return $path;
}
if ($create && defined('WINDOWS2WSL')) {
// Special case to solve Windows 2 WSL integration
$path = $this->path . "/" . $subdir;
if (mkdir($path)) {
return realpath($path);
}
}
if ($create && is_writable($this->path)) {
$path = $this->path . "/" . $subdir;

View File

@@ -38,7 +38,7 @@ $config = array(
// Version of cimage and img.php
define("CIMAGE_VERSION", "v0.8.4 (2022-05-30)");
define("CIMAGE_VERSION", "v0.8.6 (2023-10-27)");
// For CRemoteImage
define("CIMAGE_USER_AGENT", "CImage/" . CIMAGE_VERSION);
@@ -465,7 +465,7 @@ class CHttpGet
{
$type = isset($this->response['header']['Content-Type'])
? $this->response['header']['Content-Type']
: null;
: '';
return preg_match('#[a-z]+/[a-z]+#', $type)
? $type
@@ -1143,6 +1143,7 @@ class CAsciiArt
* @example http://dbwebb.se/opensource/cimage
* @link https://github.com/mosbth/cimage
*/
#[AllowDynamicProperties]
class CImage
{
@@ -2101,8 +2102,11 @@ class CImage
{
$file = $file ? $file : $this->pathToImage;
is_readable($file)
or $this->raiseError('Image file does not exist.');
// Special case to solve Windows 2 WSL integration
if (!defined('WINDOWS2WSL')) {
is_readable($file)
or $this->raiseError('Image file does not exist.');
}
$info = list($this->width, $this->height, $this->fileType) = getimagesize($file);
if (empty($info)) {
@@ -3577,8 +3581,10 @@ class CImage
return;
}
is_writable($this->saveFolder)
if (!defined("WINDOWS2WSL")) {
is_writable($this->saveFolder)
or $this->raiseError('Target directory is not writable.');
}
$type = $this->getTargetImageExtension();
$this->Log("Saving image as " . $type);
@@ -4140,6 +4146,15 @@ class CCache
return $path;
}
if ($create && defined('WINDOWS2WSL')) {
// Special case to solve Windows 2 WSL integration
$path = $this->path . "/" . $subdir;
if (mkdir($path)) {
return realpath($path);
}
}
if ($create && is_writable($this->path)) {
$path = $this->path . "/" . $subdir;

File diff suppressed because one or more lines are too long

22
webroot/tests.php Normal file
View File

@@ -0,0 +1,22 @@
<?php
$links = [
"img.php?src=car.png&v",
"img.php?src=car.png&w=700&v",
];
?><!doctype html>
<html>
<head>
<title>Links to use for testing</title>
</head>
<body>
<h1>Links useful for testing</h1>
<p>A collection of linkt to use to test various aspects of the cimage process.</p>
<ul>
<?php foreach ($links as $link) : ?>
<li><a href="<?= $link ?>"><?= $link ?></a></li>
<?php endforeach; ?>
</ul>
</body>
</html>