{"record":{"id":"435d082dbc518163","repo":"phalcon/cphalcon","slug":"height-must-be-specified","errorCode":null,"errorMessage":"Height must be specified","messagePattern":"Height must be specified","errorType":"exception","errorClass":"Phalcon\\Image\\Exceptions\\MissingHeight","httpStatus":null,"severity":"error","filePath":"phalcon/Image/Adapter/AbstractAdapter.zep","lineNumber":583,"sourceCode":"        int master = Enum::AUTO\n    ) -> void {\n        switch master {\n            case Enum::TENSILE:\n            case Enum::AUTO:\n            case Enum::INVERSE:\n            case Enum::PRECISE:\n                if (null === width || null === height) {\n                    throw new MissingDimensions();\n                }\n                break;\n            case Enum::WIDTH:\n                if (null === width) {\n                    throw new MissingWidth();\n                }\n                break;\n            case Enum::HEIGHT:\n                if (null === height) {\n                    throw new MissingHeight();\n                }\n                break;\n            default:\n                break;\n        }\n    }\n\n    private function checkResizeMaster(\n        int width = null,\n        int height = null,\n        int master = Enum::AUTO\n    ) -> int {\n        if (master === Enum::AUTO) {\n            return (this->width / width) > (this->height / height)\n                ? Enum::WIDTH\n                : Enum::HEIGHT;\n        }\n","sourceCodeStart":565,"sourceCodeEnd":601,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Image/Adapter/AbstractAdapter.zep#L565-L601","documentation":"With master = Phalcon\\Image\\Enum::HEIGHT the height is mandatory because the width is derived from the aspect ratio; a null height throws MissingHeight.","triggerScenarios":"$image->resize(800, null, Enum::HEIGHT); - height omitted while the HEIGHT master is selected.","commonSituations":"Swapped argument order relative to the HEIGHT master; dynamic height values (e.g. from request input) arriving null; copying a WIDTH example and changing only the master constant.","solutions":["Supply the height: ->resize(null, 600, Enum::HEIGHT);","Use Enum::WIDTH when only the width is known","Default the height from the source image: ->resize(null, $image->getHeight(), Enum::HEIGHT);"],"exampleFix":"// before\n$image->resize(800, null, \\Phalcon\\Image\\Enum::HEIGHT); // throws MissingHeight\n\n// after\n$image->resize(null, 600, \\Phalcon\\Image\\Enum::HEIGHT); // width derived","handlingStrategy":"validation","validationCode":"use Phalcon\\Image\\Enum;\n\nif (Enum::HEIGHT === $master && null === $height) {\n    throw new \\InvalidArgumentException('HEIGHT master requires a height');\n}\n$image->resize($width, $height, $master);","typeGuard":"function hasRequiredHeight(?int $height, int $master): bool\n{\n    return \\Phalcon\\Image\\Enum::HEIGHT !== $master || $height !== null;\n}","tryCatchPattern":"try { $image->resize($w, $h, \\Phalcon\\Image\\Enum::HEIGHT); } catch (\\Phalcon\\Image\\Exceptions\\MissingHeight $e) { $image->resize(null, $image->getHeight(), \\Phalcon\\Image\\Enum::HEIGHT); // fall back to source height\n}","preventionTips":["Match the master constant to the dimension you actually have","Default null height from the source image before calling","Use Enum::WIDTH when the width is the only known value"],"tags":["php","phalcon","image","gd","validation"],"backgroundTag":"missing-image-dimensions","analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}