PHP 7.2 GD Image with jpeg support

I’m having a heck of a time getting gd image support in PHP images. Ive successfully gotten support for png images but not jpeg. I still get gd/imagejpeg() is not defined.
my .yml file is below

 # PHP CircleCI 2.0 configuration file
 #
 # Check https://circleci.com/docs/2.0/language-php/ for more details
 #
 version: 2
 jobs:
  build:
    docker:
      # specify the version you desire here
      - image: circleci/php:7.2-cli

    working_directory: ~/repo

    steps:
      - run: sudo apt-get update && sudo apt-get install -y libpng-dev libjpeg62-turbo-
dev
      - run:
          name: Install PHP Extensions
          command: sudo docker-php-ext-install gd exif

      - checkout

      # Download and cache dependencies
      - restore_cache:
          keys:
          - v1-dependencies-{{ checksum "composer.json" }}
          # fallback to using the latest cache if no exact match is found
      - v1-dependencies-

      - run: composer install -n --prefer-dist

      - save_cache:
          paths:
            - ./vendor
          key: v1-dependencies-{{ checksum "composer.json" }}

      # run tests!
      - run: vendor/bin/phpunit ./tests --exclude-group missing-env

I’m not familiar with the docker-php-ext-install command. Could you just do it through the Ubuntu repo?

sudo apt-get install -y php-gd

I am assuming circleci/php:7.2-cli is based on Ubuntu here, of course.

I’d also suggest looking at the installations of PHP in this image. I speculate that the default repo version of PHP is 7.1, and 7.2 has been custom-compiled from scratch by CircleCI builders. If that is correct, modules would need to be installed in a non-default place. Get an SSH session on this running container, and search for PHP installations.

Our images are based on the upstream Docker Library Official images. For PHP & GD, the official instructions has an example. Go here and scroll down to the “PHP Core Extensions” section.

I would link directly but it seems like I can’t. :confused:

1 Like

Thanks so much @FelicianoTech that was exactly the pointer i needed.

1 Like