Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

T15977 gd webm #16027

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,13 @@ jobs:

- name: Run Unit Tests
if: always()
run: vendor/bin/codecept run --coverage-xml=coverage-${{ matrix.php }}.xml --ext DotReporter unit
run: vendor/bin/codecept run --coverage-xml=coverage-${{ matrix.php }}.xml unit
# run: vendor/bin/codecept run --coverage-xml=coverage-${{ matrix.php }}.xml --ext DotReporter unit

- name: Run CLI Tests
if: always()
run: vendor/bin/codecept run --coverage-xml=coverage-${{ matrix.php }}.xml --ext DotReporter cli
run: vendor/bin/codecept run --coverage-xml=coverage-${{ matrix.php }}.xml cli
# run: vendor/bin/codecept run --coverage-xml=coverage-${{ matrix.php }}.xml --ext DotReporter cli

- name: Check Release notes parser
if: runner.os == 'Linux'
Expand Down Expand Up @@ -314,26 +316,30 @@ jobs:

- name: Run Unit Tests
if: always()
run: vendor/bin/codecept run --coverage-xml=coverage-${{ matrix.php }}.xml --ext DotReporter unit
run: vendor/bin/codecept run --coverage-xml=coverage-${{ matrix.php }}.xml unit
# run: vendor/bin/codecept run --coverage-xml=coverage-${{ matrix.php }}.xml --ext DotReporter unit

- name: Run CLI Tests
if: always()
run: vendor/bin/codecept run --coverage-xml=coverage-${{ matrix.php }}.xml --ext DotReporter cli
run: vendor/bin/codecept run --coverage-xml=coverage-${{ matrix.php }}.xml cli
# run: vendor/bin/codecept run --coverage-xml=coverage-${{ matrix.php }}.xml --ext DotReporter cli

- name: Run Integration Tests
env:
DATA_REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
DATA_MEMCACHED_PORT: ${{ job.services.memcached.ports['11211'] }}
if: always()
run: vendor/bin/codecept run --coverage-xml=coverage-${{ matrix.php }}.xml --ext DotReporter integration
run: vendor/bin/codecept run --coverage-xml=coverage-${{ matrix.php }}.xml integration
# run: vendor/bin/codecept run --coverage-xml=coverage-${{ matrix.php }}.xml --ext DotReporter integration

- name: Run Database Tests (Common)
env:
DATA_REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
DATA_MEMCACHED_PORT: ${{ job.services.memcached.ports['11211'] }}
DATA_MYSQL_USER: root
if: always()
run: vendor/bin/codecept run --coverage-xml=coverage-${{ matrix.php }}.xml --ext DotReporter database -g common
run: vendor/bin/codecept run --coverage-xml=coverage-${{ matrix.php }}.xml database -g common
# run: vendor/bin/codecept run --coverage-xml=coverage-${{ matrix.php }}.xml --ext DotReporter database -g common

- name: Run Database Tests (MySQL)
env:
Expand All @@ -342,14 +348,16 @@ jobs:
DATA_MEMCACHED_PORT: ${{ job.services.memcached.ports['11211'] }}
DATA_MYSQL_USER: root
if: always()
run: vendor/bin/codecept run --coverage-xml=coverage-${{ matrix.php }}.xml --ext DotReporter database --env mysql -g mysql
run: vendor/bin/codecept run --coverage-xml=coverage-${{ matrix.php }}.xml database --env mysql -g mysql
# run: vendor/bin/codecept run --coverage-xml=coverage-${{ matrix.php }}.xml --ext DotReporter database --env mysql -g mysql

- name: Run Database Tests (Sqlite)
env:
DATA_REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
DATA_MEMCACHED_PORT: ${{ job.services.memcached.ports['11211'] }}
if: always()
run: vendor/bin/codecept run --coverage-xml=coverage-${{ matrix.php }}.xml --ext DotReporter database --env sqlite -g sqlite
run: vendor/bin/codecept run --coverage-xml=coverage-${{ matrix.php }}.xml database --env sqlite -g sqlite
# run: vendor/bin/codecept run --coverage-xml=coverage-${{ matrix.php }}.xml --ext DotReporter database --env sqlite -g sqlite

- name: Run Database Tests (Postgres)
env:
Expand All @@ -359,7 +367,8 @@ jobs:
DATA_REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
DATA_MEMCACHED_PORT: ${{ job.services.memcached.ports['11211'] }}
if: always()
run: vendor/bin/codecept run --coverage-xml=coverage-${{ matrix.php }}.xml --ext DotReporter database --env pgsql -g pgsql
run: vendor/bin/codecept run --coverage-xml=coverage-${{ matrix.php }}.xml database --env pgsql -g pgsql
# run: vendor/bin/codecept run --coverage-xml=coverage-${{ matrix.php }}.xml --ext DotReporter database --env pgsql -g pgsql

# - name: Run Database Tests (SQL Server)
# env:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG-5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- Reverted to single quotes when volt code generates PHP code.
- Any `tag` helpers only accept parameters with double quotes
- Renamed `Phalcon\Tag::form()` to `Phalcon\Tag::formLegacy` (helper `form_legacy`) [#16019](https://github.com/phalcon/cphalcon/issues/16019)
- Fixed rendering for `webp` images for `Phalcon\Image\Adapter\Gd` [#15977](https://github.com/phalcon/cphalcon/issues/15977)

# [5.0.0rc3](https://github.com/phalcon/cphalcon/releases/tag/v5.0.0RC3) (2022-07-12)

Expand Down
167 changes: 106 additions & 61 deletions phalcon/Image/Adapter/Gd.zep
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ class Gd extends AbstractAdapter
}

imagesavealpha(this->image, true);

} else {
if unlikely !width || !height {
throw new Exception(
Expand Down Expand Up @@ -451,6 +450,8 @@ class Gd extends AbstractAdapter
imagepng(this->image);
} elseif strcmp(ext, "wbmp") == 0 {
imagewbmp(this->image);
} elseif strcmp(ext, "webp") == 0 {
imagewebp(this->image);
} elseif strcmp(ext, "xbm") == 0 {
imagexbm(this->image, null);
} else {
Expand Down Expand Up @@ -510,75 +511,119 @@ class Gd extends AbstractAdapter

protected function processSave(string file, int quality)
{
var ext;

let ext = pathinfo(file, PATHINFO_EXTENSION);

// If no extension is given, revert to the original type.
if !ext {
let ext = image_type_to_extension(this->type, false);
}

let ext = strtolower(ext);

if strcmp(ext, "gif") == 0 {
let this->type = 1;
let this->mime = image_type_to_mime_type(this->type);

imagegif(this->image, file);

return true;
}

if strcmp(ext, "jpg") == 0 || strcmp(ext, "jpeg") == 0 {
let this->type = 2;
let this->mime = image_type_to_mime_type(this->type);
// var ext;
//
// let ext = pathinfo(file, PATHINFO_EXTENSION);
//
// // If no extension is given, revert to the original type.
// if !ext {
// let ext = image_type_to_extension(this->type, false);
// }
//
// let ext = strtolower(ext);
//
// if strcmp(ext, "gif") == 0 {
// let this->type = 1;
// let this->mime = image_type_to_mime_type(this->type);
//
// imagegif(this->image, file);
//
// return true;
// }
//
// if strcmp(ext, "jpg") == 0 || strcmp(ext, "jpeg") == 0 {
// let this->type = 2;
// let this->mime = image_type_to_mime_type(this->type);
//
// if quality >= 0 {
// if quality < 1 {
// let quality = 1;
// } elseif quality > 100 {
// let quality = 100;
// }
//
// imagejpeg(this->image, file, quality);
// } else {
// imagejpeg(this->image, file);
// }
//
// return true;
// }
//
// if strcmp(ext, "png") == 0 {
// let this->type = 3;
// let this->mime = image_type_to_mime_type(this->type);
//
// imagepng(this->image, file);
//
// return true;
// }
//
// if strcmp(ext, "wbmp") == 0 {
// let this->type = 15;
// let this->mime = image_type_to_mime_type(this->type);
//
// imagewbmp(this->image, file);
//
// return true;
// }
//
// if strcmp(ext, "xbm") == 0 {
// let this->type = 16;
// let this->mime = image_type_to_mime_type(this->type);
//
// imagexbm(this->image, file);
//
// return true;
// }
//
// throw new Exception(
// "Installed GD does not support '" . ext . "' images"
// );

switch this->type {
case IMAGETYPE_GIF:
imagegif(this->image, file);
break;

case IMAGETYPE_JPEG:
case IMAGETYPE_JPEG2000:
if quality >= 0 {
if quality < 1 {
let quality = 1;
} elseif quality > 100 {
let quality = 100;
}

if quality >= 0 {
if quality < 1 {
let quality = 1;
} elseif quality > 100 {
let quality = 100;
imagejpeg(this->image, file, quality);
} else {
imagejpeg(this->image, file);
}
break;

imagejpeg(this->image, file, quality);
} else {
imagejpeg(this->image, file);
}

return true;
}

if strcmp(ext, "png") == 0 {
let this->type = 3;
let this->mime = image_type_to_mime_type(this->type);

imagepng(this->image, file);

return true;
}

if strcmp(ext, "wbmp") == 0 {
let this->type = 15;
let this->mime = image_type_to_mime_type(this->type);

imagewbmp(this->image, file);
case IMAGETYPE_PNG:
imagepng(this->image, file);
break;

return true;
}
case IMAGETYPE_WEBP:
imagewebp(this->image, file);
break;

if strcmp(ext, "xbm") == 0 {
let this->type = 16;
let this->mime = image_type_to_mime_type(this->type);
case IMAGETYPE_WBMP:
imagewbmp(this->image, file);
break;

imagexbm(this->image, file);
case IMAGETYPE_XBM:
imagexbm(this->image, file);
break;

return true;
default:
throw new Exception(
"Installed GD does not support " . this->mime . " images"
);
}

throw new Exception(
"Installed GD does not support '" . ext . "' images"
);
return true;
}

protected function processSharpen(int amount)
Expand Down
2 changes: 1 addition & 1 deletion tests/_data/assets/config/config-with.in-file.name.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ options.charset = DATA_MYSQL_CHARSET

[image]
adapter = imagick
file = PATH_DATA"assets/images/phalconphp.jpg"
file = PATH_DATA"assets/images/example-jpg.jpg"

[logger]
name = "my-logger"
Expand Down
2 changes: 1 addition & 1 deletion tests/_data/assets/config/factory.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ options.charset = DATA_MYSQL_CHARSET

[image]
adapter = imagick
file = PATH_DATA"assets/images/phalconphp.jpg"
file = PATH_DATA"assets/images/example-jpg.jpg"

[logger]
name = "my-logger"
Expand Down
Binary file added tests/_data/assets/images/example-gif.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/_data/assets/images/example-wbmp.wbmp
Binary file not shown.
Loading