This has as much, or everything, to do with "musical grammar," i.e. appropriate note names (A B C D E F G) and their spelling, regardless of the key you are in.
The QUANTITY of any interval, 2nd, 3rd, 4th, 5th, etc. is found in how many alpha (letter) names distance apart any two pitches are.
The QUALITY of any interval (perfect / major / minor/ augmented = enlarged / diminished = lessened) is found in the number of half steps between the two pitches.
Regardless of any alterations using accidentals, in the key signature -- or written in, if spelled C up to E, the quantity is 'a third.'
It is the distance in the number of half-steps from one note to the next that determines the quality of Perfect, Major, Minor, Augmented (increased) and Diminished (lessened.)
C up to E happens to be major, with four additional half steps distance above the C.
C up to Eb is quantatively still 'a third' because it is still 'C to an E,' but the Eb is three additional half-steps distance above (the defining number of semitones apart qualifying minor)
This is a constant.
Think of a keyboard, and picture, 'white notes in the key of C.'
C up to E and C down to A. Both thirds. Count the number of half steps between, the C up to E is a major third (four half-steps above) while the C down to A is a minor third (three half-steps below.)
IF you instead spelled your perfect fifth as C, Gb, that is no longer 'perfect' (perfect being a quality like major or minor). That Gb lessens the number of half-steps that make a perfect fifth 'perfect,' and in lessening it, you have diminished it.
C up to G = 5th, perfect
C up to Gb = 5th, diminished.
C up to F#, the same no. of half-steps apart, because it is C up to F, is an augmented fourth :-)
C up to G# = 5th, augmented. C up to Ab, the same distance, is a minor sixth.
Count / measure the distance between the letter / alpha names to determine the general quantity, 5th,m 7th, 4th, etc.
Count / measure the distance of the number of semi-tones between the pitches to determine their quality, perfect, major, minor, diminished, augmented.