{"record":{"id":"16f13496542a964a","repo":"wasabeef/android-gpuimage","slug":"rotation-is-an-unknown-rotation-needs-to-be-eit","errorCode":null,"errorMessage":"<rotation> is an unknown rotation. Needs to be either 0, 90, 180 or 270!","messagePattern":"<rotation> is an unknown rotation\\. Needs to be either 0, 90, 180 or 270!","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"library/src/main/java/jp/co/cyberagent/android/gpuimage/util/Rotation.java","lineNumber":61,"sourceCode":"     * Create a Rotation from an integer. Needs to be either 0, 90, 180 or 270.\n     *\n     * @param rotation 0, 90, 180 or 270\n     * @return Rotation object\n     */\n    public static Rotation fromInt(int rotation) {\n        switch (rotation) {\n            case 0:\n                return NORMAL;\n            case 90:\n                return ROTATION_90;\n            case 180:\n                return ROTATION_180;\n            case 270:\n                return ROTATION_270;\n            case 360:\n                return NORMAL;\n            default:\n                throw new IllegalStateException(\n                        rotation + \" is an unknown rotation. Needs to be either 0, 90, 180 or 270!\");\n        }\n    }\n}\n","sourceCodeStart":43,"sourceCodeEnd":66,"githubUrl":"https://github.com/wasabeef/android-gpuimage/blob/ceea576ec931c2968431ad46f1fb2e6d68a542e2/library/src/main/java/jp/co/cyberagent/android/gpuimage/util/Rotation.java#L43-L66","documentation":"Rotation.fromInt(int) converts an integer (0, 90, 180, 270 — 360 maps back to NORMAL) to the Rotation enum. Any other value throws IllegalStateException(\"<rotation> is an unknown rotation. Needs to be either 0, 90, 180 or 270!\") with the offending value in the message.","triggerScenarios":"Calling Rotation.fromInt() with values like 45, -90, or an EXIF orientation code not converted to degrees first — e.g. passing raw android.media.ExifInterface orientation constants (1-8) instead of computed degrees.","commonSituations":"Mapping camera sensor or EXIF metadata to rotations without converting orientation codes to degrees; applying an arbitrary user-chosen angle; sign errors producing negative rotation values.","solutions":["Normalize the angle before calling: ((angleDegrees % 360) + 360) % 360 so values like -90 become 270.","Convert EXIF orientation constants (1-8) to degrees 0/90/180/270 before invoking fromInt().","Use the normalization helper (Rotation.NORMAL/ROTATION_90...) or guard with a validity check: deg % 90 == 0 && deg in 0..270."],"exampleFix":"// before\n Rotation rot = Rotation.fromInt(exifOrientation); // exifOrientation is 1..8\n// after\n int degrees = exifDegreesFromOrientation(exifOrientation); // maps 1..8 to 0/90/180/270\n Rotation rot = Rotation.fromInt(((degrees % 360) + 360) % 360);","handlingStrategy":"validation","validationCode":"int normalized = ((degrees % 360) + 360) % 360;\nif (normalized != 0 && normalized != 90 && normalized != 180 && normalized != 270) {\n    throw new IllegalArgumentException(\"degrees must be a multiple of 90: \" + degrees);\n}\nRotation rotation = Rotation.fromInt(normalized);","typeGuard":null,"tryCatchPattern":"try {\n    Rotation rotation = Rotation.fromInt(degrees);\n} catch (IllegalStateException e) {\n    Rotation rotation = Rotation.NORMAL; // safe default on bad input\n}","preventionTips":["Normalize angles modulo 360 before conversion","Convert EXIF orientation codes (1-8) to degrees before calling fromInt","Clamp/round arbitrary user angles to the nearest multiple of 90"],"tags":["android","gpuimage","enum","value-out-of-range"],"backgroundTag":"invalid-enum-value","analyzedSha":"ceea576ec931c2968431ad46f1fb2e6d68a542e2","analyzedAt":"2026-09-11T16:56:13.742Z","contentChangedAt":"2026-09-11T16:56:13.742Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}